Please use code tags when posting code.
Sample Input:
3 2
1 2
2 3
StringTokenizer st = new StringTokenizer(br.readLine());
At this point st will have two tokens ("3" and "2")
int n = Integer.parseInt(st.nextToken());
int e = Integer.parseInt(st.nextToken());
After reading n and e there are no more tokens in st.
i = Integer.parseInt(st.nextToken());
j =Integer.parseInt(st.nextToken());
There are no tokens to read from st so an NZEC is returned. You need to read a new line from the input to load into st before this.