public void solve() throws IOException {
    int T = nextInt();
    for (int t = 1; t <= T; t++) {
      int N = nextInt();
      long ans = -1;
      if (N != 0) {
        boolean[] hit = new boolean[10];
        int count = 0;
        long value = N;
        while (value > 0 && count < 10) {
          long temp = value;
          while (temp > 0) {
            int digit = (int) (temp % 10);
            if (!hit[digit]) {
              hit[digit] = true;
              count++;
            }
            temp /= 10;
          }
          if (count == 10) {
            ans = value;
          }
          value += N;
        }
      }
      if (ans == -1) {
        out.format("Case #%d: INSOMNIA%n", t);
      } else {
        out.format("Case #%d: %d%n", t, ans);
      }
    }
  }