'use strict';

const pipe=Symbol();Function.prototype[pipe]=function(nextFunc){const that=this;return function(I){return nextFunc(that(I));};};
const curry=Symbol();Function.prototype[curry]=function(){  const that=this;  return function(firstArg){    const a=firstArg;    return function(){      return that(a,...arguments);    };  };};
const exec=Symbol();Function.prototype[exec]=function(input){  const that=this;  return that(input);};

function pre1(input){
  return input.
  split(/\n|\r/).
  map(
    str=>
      str.
      split(/\s+/).
      map(x=>x-0)
  );
}

function pre2(input){
  return [
    [null].concat(input[1]),
    input.slice(2),
    [false].concat(new Array(input[0][1]).fill(true)),
  ];
}

function compare(input){
  const H=input[0];
  const M=input[1];
  const G=input[2];
  
  M.forEach(function(AB){
    const [i,j]=AB;
    const Hi=H[i];
    const Hj=H[j];
    if(Hi===Hj){
      G[i]=G[j]=false;
    }else{
      G[Hi<Hj?i:j]=false;
    }
  });
  
  return G;
} 

function count(G){
  return G.reduce(
    (acc,crr)=>acc+(crr?1:0),
    0
  );
}

function showResult(val){
  console.log(val);
  return null;
}

pre1
[pipe](pre2)
[pipe](compare)
[pipe](count)
[pipe](showResult)
[exec](
  require('fs').
  readFileSync('/dev/stdin','utf-8')
);

