import java.io.*;
public class ST1 extends Thread {
static boolean useSynchronize=false;
static String datafile;
static int sum1=0;
static int sum2=0;
private int numThreads, myNum;
private BufferedReader br;
private ST1(int numThreads, int myNum) throws IOException {
this.numThreads = numThreads;
this.myNum = myNum;
br = new BufferedReader(new InputStreamReader(new FileInputStream(datafile)));
}
public void run() {
try {
String line = br.readLine();
int mysum = 0;
int count=0;
while (line!=null) {
if (count%numThreads==myNum) {
if (useSynchronize) {
synchronized(datafile) {
sum1 += Integer.parseInt(line.trim());
}
} else
sum1 += Integer.parseInt(line.trim());
mysum += Integer.parseInt(line.trim());
}
count++;
System.out.print(myNum);
if (count%50==0) System.out.println();
line = br.readLine();
}
sum2 += mysum;
} catch (IOException ioe) {System.out.println("IO Exception in thread "+Thread.currentThread().getName()); }
}
public static void main(String[] a) throws Exception {
int n = Integer.parseInt(a[0]);
datafile = a[1];
useSynchronize = a.length>2;
ST1[] st = new ST1[n];
for (int i=0; i<n; i++)
st[i] = new ST1(n,i);
for (int i=0; i<n; i++)
st[i].start();
for (int i=0; i<n; i++)
st[i].join();
System.err.println("\n\nsum1 = "+sum1);
System.err.println("sum2 = "+sum2);
}
}