public void solve() throws IOException {
    ArrayList<String> index = new ArrayList<String>(15504);
    int[] val = new int[6];
    val[5] = 15;
    index.add(toString(val));
    for (int x = 1; x < 15504; x++) {
      for (int y = 5; y >= 0; y--) {
        if (val[y] != 0) {
          val[y - 1]++;
          val[y]--;
          int tot = 0;
          for (int z = y; z < 6; z++) {
            tot += val[z];
            val[z] = 0;
          }
          val[5] = tot;
          break;
        }
      }
      index.add(toString(val));
    }
    
    String act;
    int num = 0;
    while (!(act = nextToken()).equals("e")) {
      num++;
      if (act.equals("u")) {
        int i = nextInt();
        System.out.format("Case %d: %s%n", num, index.get(i));
      } else if (act.equals("m")) {
        StringBuilder build = new StringBuilder();
        for (int x = 0; x < 6; x++) {
          if (x != 0) {
            build.append(" ");
          }
          build.append(nextToken());
        }
        System.out.format("Case %d: %d%n", num, index.indexOf(build.toString()));
      }
    }
  }