import java.io.*; public class Input { private int n, m; private BufferedReader reader; private int[] arr; private int count; public Input() { count = 0; try{ reader = new BufferedReader(new FileReader("input.txt")); String s = reader.readLine(); String[] ss = s.split(" "); n = Integer.parseInt(ss[0]); m = Integer.parseInt(ss[1]); arr = new int[2*m]; s = reader.readLine(); ss = s.split(" "); for (int i=0; i<2*m; i++) arr[i] = Integer.parseInt(ss[i]); } catch(FileNotFoundException fnfe){ fnfe.printStackTrace(); } catch(IOException ioe) { ioe.printStackTrace(); } } public int getN() { return n; } public int getM() { return m; } public int getInt() { int x = -1; if (count < 2*m) { x = arr[count]; count++; } return x; } } /* An example for the input.txt file: 7 8 0 2 1 4 2 5 1 6 1 6 0 4 6 0 4 5 */