NZEC Error in java can some one explain why

import java.util.*;

class PairSome {
public long tk;
public int ck;

PairSome(long tk, int ck) {
    this.ck = ck;
    this.tk = tk;
}

}

public class ThreeDimMatrix {

public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long rows = in.nextLong();
    long cols = in.nextLong();
    int height = in.nextInt();
    long cells = rows * cols;
    long sum = 0;
    List<PairSome> list = new ArrayList<PairSome>();
    long tk;
    int ck;
    for (int i = 0; i < height; i++) {
        tk = in.nextLong();
        ck = in.nextInt();
        sum += tk;
        list.add(new PairSome(tk, ck));
    }
    if (sum < cells) {
        System.out.println("Impossible");
        return;
    }
    long minCost = 0;
    Comparator comparator = new Comp();
    if (list != null && !list.isEmpty()) {
        Collections.sort(list, comparator);
        long cellsPainted = 0;
        for (PairSome pairSome : list) {
            if (cellsPainted + pairSome.tk < cells) {
                minCost += (pairSome.tk * pairSome.ck);
                cellsPainted += pairSome.tk;
            } else {
                minCost += ((cells - cellsPainted) * pairSome.ck);
                break;
            }
        }
    }
    System.out.println(minCost);
}

}

class Comp implements Comparator {

@Override
public int compare(PairSome e1, PairSome e2) {
    if (e1.ck > e2.ck) {
        return 1;
    } else {
        return -1;
    }
}

}
}

//