// Arup Guha
// 4/30/2007
// Solution to 2007 UCF HS Problem: Radio, written in practice contest

import java.util.*;
import java.io.*;

public class radio {

  public static void main(String[] args) throws IOException {

    Scanner fin = new Scanner(new File("radio.in"));

    // Go through cases.
    int numcases = fin.nextInt();
    for (int z=1; z<=numcases; z++) {

      // Frequency array is easy way to do this.
      int[] minutes = new int[360];
      for (int i=0; i<360; i++) minutes[i]=0;

      // Go through each station.
      int numstations = fin.nextInt();
      for (int i=0; i<numstations; i++) {
        int x = fin.nextInt();
        int y = fin.nextInt();

        // Here is when we're on commercial.
        for (int j=0; j<360; j++) {
          if (j%(x+y) >= x)
            minutes[j]++;
        }

      }

      // See when there are too many commercials!
      int cram = 0;
      for (int i=0; i<360; i++)
        if (minutes[i] >= 2)
          cram++;

      // Here is our answer.
      System.out.println("Study session #"+z+" has "+cram+" minute(s) of pure cramming.  Excellent!");
    }

    fin.close();
  }
}