public void solve() throws IOException {
    int n = nextInt();
    int m = nextInt();

    Edge[][] adjmat = new Edge[n][n];
    for (int x = 0; x < m; x++) {
      int from = nextInt() - 1;
      int to = nextInt() - 1;
      Edge temp = new Edge(nextInt(), nextInt());
      adjmat[from][to] = temp;
      adjmat[to][from] = temp;
    }
    State init = new State(0, -1, Integer.MAX_VALUE);
    ArrayList<State> bfs = new ArrayList<State>();
    bfs.add(init);
    while (!bfs.isEmpty()) {
      State cur = bfs.remove(0);
      Edge[] list = adjmat[cur.node];
      for (int x = 0; x < list.length; x++) {
        if (list[x] != null) {
          Edge temp = list[x];
          int lower = Math.max(cur.lower, temp.lower);
          int upper = Math.min(cur.upper, temp.upper);
          if (x == n - 1 && upper - lower > loyalty) {
            loyalty = Math.max(upper - lower, loyalty);
          } else if (upper - lower > loyalty) {
            System.out.println(upper - lower + " " + cur.node);
            bfs.add(new State(x, lower, upper));
          }
        }
      }
    }
    if (loyalty != -1)
      System.out.println(loyalty);
    else
      System.out.println("Nice work, Dima");
  }