Format of files:
First line contains value of N Second line contains value of M Next M lines contain relationships as pairs of elements