public void solve() throws IOException {
    long C = nextLong();
    int n = nextInt();
    int size = 0;
    boolean possible = true;
    for (int x = 0; x < n; x++) {
      long off = nextLong();
      long enter = nextLong();
      long wait = nextLong();
      
      size -= off;
      if (size < 0) {
        possible = false;
      }
      
      size += enter;
      if (size > C) {
        possible = false;
      }
      
      if ((size != C || x == n - 1) && wait > 0) {
        possible = false;
      }
    }
    if (size != 0) {
      possible = false;
    }
    if (possible) {
      System.out.println("possible");
    } else {
      System.out.println("impossible");
    }
  }