let str;
while(str = readline()){
  let people = readline();
  let laji = readline();
  let piao = readline();

  let sum=0,res={};
  let pArr = people.split(' ');
  let piArr = piao.split(' ');
  for(let v in piArr){
    if(pArr.includes(piArr[v])){
      if(res[piArr[v]]){
        res[piArr[v]]++;
      }else{
        res[piArr[v]] = 1;
      }
    }else{
      sum++;
    }
  }

  for(let v of pArr){
    if(res[v]){
      console.log(v+' :'+' '+res[v]);
    }else{
      console.log(v+' :'+' 0');
    }
  }
  console.log('Invalid :'+' '+sum);
}