#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define wfile freopen("output.txt", "w", stdout)
#define rfile freopen("input.txt", "r", stdin)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
void enable_io(){
    #ifdef LOCAL_PROJECT
        wfile;
        rfile;
    #endif
}
pair<int,int> solve(){
    int n;
    cin >> n;
    std::vector<int> e(n,0);
    std::vector<int> r(n,0);
    ll firstround = 0;
    ll bestans = -1;
    for (int i = 0; i < n; ++i)
    {
        cin >> e[i] >> r[i];
        firstround += e[i];
    }
    ll running_sum = 0;
    ll min_deletions = 1e9;
    ll cur_deletions = 0;
    priority_queue<pair<int,int>> good;
    for(int i = 0; i < n; i++){
        if(e[i] + r[i] <= firstround){  
            running_sum += e[i];
            good.push({e[i] + r[i],i});
        }
        else{
            if(bestans == running_sum + firstround)
			    min_deletions = min(min_deletions, cur_deletions);
			else if(bestans < running_sum + firstround)
			    min_deletions = cur_deletions;
			bestans = max(bestans, running_sum + firstround);
            cur_deletions++;
            firstround -= e[i];
            while(!good.empty() && good.top().first > firstround){
                firstround -= e[good.top().second];
                running_sum -= e[good.top().second];
                good.pop();
                cur_deletions++;
            }
        }
    }
    if(bestans == running_sum + firstround)
	    min_deletions = min(min_deletions, cur_deletions);
	else if(bestans < running_sum + firstround)
	    min_deletions = cur_deletions;
	bestans = max(bestans, running_sum + firstround);
    if(good.size() > 1){
        return {n - good.size(),-1};
    }
    return {min_deletions,bestans};
}
int main(int argc, char const *argv[])
{   
    fastio;
    enable_io();
    int T = 1;
    cin >> T;
    for(int tests = 1; tests <= T; tests++){
        auto ans = solve();   
        string out = (ans.second == -1)? to_string(ans.first) + " INDEFINITELY": to_string(ans.first) + " " + to_string(ans.second); 
        cout << "Case #" << tests << ": " << out << endl;
    }
    return 0;
}
