#include <iostream>
#include <vector>
using namespace std;

int main()
{
  int n, I = 0;
  for(cin >> n; n > 0; --n)
  {
    int m; cin >> m;

    vector<pair<int, int> > events(m);
    for(int i = 0; i < m; ++i)
    {
      int d, s, e;
      cin >> d >> s >> e;
      events[i] = make_pair(10000*d + e, 10000*d + s);
    }

    sort(events.begin(), events.end());

    int count = 0, time = 0;
    for(int i = 0; i < m; ++i)
      if(events[i].second >= time) // start
      {
        ++count; 
        time = events[i].first; // end
      }

    cout << "Scenario #" << ++I << ":\n";
    cout << count << endl << endl;
  }
}
