import java.util.*;

public class splitone_AN {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int T = s.nextInt();
    for (int tc = 0; tc < T; tc++) {
      int n = s.nextInt();
      int pd = 0, pt = 0, d = 0, t = 0;
      boolean found = false;
      for (int i = 0; i < n; i++) {
        d = s.nextInt();
        t = s.nextInt();
        if (d >= 5280 && !found) {
          System.out.println(pt + (5280 - pd) * (t - pt) / (d - pd));
          found = true;
        }
        pd = d;
        pt = t;
      }
    }
  }
}
