Recoding data in a matrix from an existing file

Hi, I was wondering if someone would be able to help with extrapolating information from a file and filling an existing matrix with that information.

I have made a matrix like this (file 1):

  A B C D  
1
2
3
4

I have another file with data like this (file 2):

1 A
1 C
3 C
4 B
4 D

I'd like to take the data and recode it where it looks like this, whereby if the information in file 2 exists, I'd like it to be marked as a "Y" in the matrix, and "N" if it is missing.
The desired output looks like this:

  A B C D  
1 Y N Y N 
2 N N N N 
3 N N Y N 
4 N Y N Y  

My actual file has about 600 columns and 500 rows. Does anyone have a good idea regarding how to do this? Any help would be greatly appreciated!

---------- Post updated at 07:15 PM ---------- Previous update was at 06:43 PM ----------

Please ignore, I found a working solution after a more refined search through the help archives. Cheers

You could also try this:

awk '
NR==1{
   T=$0;
   for(i=1;i<=NF;i++) H[$i]
   next}
FNR==NR{F[NR]=$1;R[$1]; next}
$1 in R && $2 in H {G[$1,$2]}
END{
   print T;
   c=split(T, H);
   for(i=2;i<=FNR;i++) {
     $1=F
     for(j=1;j<=c;j++) $(j+1) = ($1 SUBSEP H[j] in G)?"Y":"N"
     print
   }
}' file1 file2