public void solve() throws IOException {
    int cases = nextInt();
    for (int n = 0; n < cases; n++) {
      int num = nextInt();
      int start = nextInt();
      int largest = start;
      while (start > 1) {
        // System.out.println(start);
        if (start % 2 == 0)
          start /= 2;
        else
          start = start * 3 + 1;
        largest = Math.max(start, largest);
      }
      System.out.println(num + " " + largest);
    }
  }