
const fs = require('fs');
const readline = require('readline');


var result = [];



const readInterface = readline.createInterface({
  input : fs.createReadStream('/home/elastic/BP/skweb/server/scnc2/answers'),
  console : false
});


readInterface.on('line', function(line){
  var tokens = line.split(" ");
  var id_query = parseInt(tokens[0]);
  var id_document = parseInt(tokens[1]);
//  console.log([id_query]);

  if (!(id_query  in result)){
    result[id_query]=[id_document];
  }
  else {
    result[id_query].push(id_document);
  }

 

// console.log(result);
});


readInterface.on('close', function() {  
	for (let i = 0 ; i < result.length; i++){
	  
	  console.log(i);
	  console.log(result[i]);
	}
	console.log("koniec");
});


