#include<bits/stdc++.h>usingnamespace std;#define pb push_back#define mp make_pair#define fi first#define se secondtypedeflonglong ll;typedefunsignedlonglong ull;typedef pair<int,int> PII;typedef pair<ll, ll> pll;constint mod =1e9+7;constint N =1e5+10;constint INF =0x3f3f3f3f;
ll qpow(ll base, ll n){ll ans =1;while(n){if(n &1) ans = ans * base % mod; base = base * base % mod; n >>=1;}return ans;}
ll gcd(ll a, ll b){return b ?gcd(b, a % b): a;}
ll a[N], b[N], c[N <<1];int v[N <<1], vis[N], tot, st[N <<1];int head[N <<1], ver[N <<1], nex[N <<1];voidadd(int x,int y){
ver[++ tot]= y;
nex[tot]= head[x];
head[x]= tot;}voiddfs(int u){
st[u]=1;for(int i = head[u]; i ; i = nex[i]){int x = ver[i];-- v[x];if(!st[x]&& v[x]<=1){dfs(x);}}return;}intmain(){int t;
cin >> t;int cas =0;while(t --){int n;scanf("%d",&n);fill(v +1, v +1+2* n,0);fill(head +1, head +1+2* n,0);fill(st +1, st +1+2* n,0);
tot =0;for(int i =1; i <= n;++ i){scanf("%lld %lld",&a[i],&b[i]);
c[++ tot]= a[i];
c[++ tot]= b[i];
vis[i]=0;}sort(c +1, c +1+ tot);int m =unique(c +1, c +1+ tot)-(c +1);for(int i =1; i <= n;++ i){
a[i]=lower_bound(c +1, c +1+ m, a[i])- c;
b[i]=lower_bound(c +1, c +1+ m, b[i])- c;++ v[a[i]];++ v[b[i]];}
tot =0;for(int i =1; i <= n;++ i){add(a[i], b[i]);add(b[i], a[i]);}for(int i =1; i <=2* n;++ i){if(v[i]<=1&&!st[i]){dfs(i);}}int ans =0;for(int i =1; i <= n;++ i){if(v[a[i]]<=1|| v[b[i]]<=1){
ans ++;
vis[i]=1;}}fill(v +1, v +1+2* n,0);for(int i =1; i <= n;++ i){if(!vis[i]){if(!v[a[i]]){
v[a[i]]=1;++ ans;}if(!v[b[i]]){
v[b[i]]=1;++ ans;}}}printf("Case #%d: %d\n",++ cas, ans);}return0;}
K __int128
#include<bits/stdc++.h>usingnamespace std;#define mod 1000000007#define INF 0x3f3f3f3f#define pi 3.141592654typedeflonglong ll;constint N =1e5+5;inline __int128 read(){
__int128 x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')
f=-1;
ch=getchar();}while(ch>='0'&&ch<='9'){
x=x*10+ch-'0';
ch=getchar();}return x*f;}inlinevoidprint(__int128 x){if(x<0){putchar('-');
x=-x;}if(x>9)print(x/10);putchar(x%10+'0');}
__int128 a[N],b[N],mins[N];
__int128 sum[N];int pos[N];boolcmp(int x,int y){return sum[x]>sum[y];}intmain(){int t,n,cas=1;cin>>t;while(t--){
cin>>n;
sum[0]=0;for(int i =1; i<= n ; i++){
a[i]=read();
sum[i]= sum[i-1]+a[i];
pos[i]= i;//print(a[i]);}
mins[0]=1e8;for(int i =1; i<=n ; i++){
b[i]=read();
mins[i]=min(b[i],mins[i-1]);}sort(pos+1,pos+1+n,cmp);
__int128 tem =0,ans =0;int p=n+1;for(int i =1; i<=n ; i++){//print(ans);if(pos[i]>= p)continue;
p = pos[i];//print(mins[p]);print(sum[p]);//printf("%lld %d %lld\n",mins[p],p,ss);
ans = ans +((mins[p]-tem)* sum[p]);
tem = mins[p];if(tem == b[1])break;}printf("Case #%d: ",cas++);print(b[1]);printf(" ");print(ans);printf("\n");}return0;}
G 暴力#include<bits/stdc++.h>using namespace std;map<string,int>id;struct hh{ int a; int b; int c; int d; int sh[5];}e[510];char qh[17][20]={"","one","two","three","*","oval","squiggle","diamond","*","solid","open","str