#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define llu unsigned long long
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define PI 3.14159265
#define MOD 1000000007
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define DESYNC ios::sync_with_stdio(0); cin.tie(0);
#define deb(x) cerr << ">> " << #x << " : " << x << "\n"
#define print(a) for(auto x : a) cout << x << " "; cout << endl;

using namespace std;

const ll inf = 1e18 + 42;

const ll M = 998244353;

ll power(ll x, ll y) {
	if (y == 0) return 1;
	if (y & 1) return (x * power(x, y - 1));
	ll t = power(x, y / 2);
	return (t * t);
}

const ll MAX = 1e6 + 5;

// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

void ahShitHereWeGoAgain()
{
	ll n;
	cin >> n;
	if(n == 1)
	{
		cout << 1 << endl;
		return;
	}
	ll x = log2(n) + 1;
	// deb(x);
	ll ans = 0;
	// ans += power(2, x) - 1;
	// // deb(ans);
	// n = n - power(2, x - 1);
	// if(n == 0)
	// {
	// 	cout << ans << endl;
	// 	return;
	// }
	// x = log2(n) + 1;
	while(1)
	{
		ans += power(2, x) - 1;
		n = n - power(2, x - 1);
		if(n == 0)
			break;
		x = log2(n) + 1;
	}
	cout << ans << endl;
}

int main()
{
	DESYNC
	ll t = 1;
	cin >> t;
	while (t--)
		ahShitHereWeGoAgain();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define inf 0x3f3f3f3f
#define INF 0xffffffff
#define il inline
#define pb push_back
#define db double
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define fi first
#define se second
const int mod = 1e9+7;
il ll read()
{
	char ch = getchar();
	ll p = 1,data = 0;
	while(ch<'0'||ch>'9')
	{
		if(ch == '-')p = -1;
		ch = getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		data = (data<<3)+(data<<1)+(ch^48);
		ch = getchar();
	}
	return p*data;
}
il ll lowbit(ll a)
{
	return a&(-a);
}
il ll qpow(ll a,ll b)
{
	ll r = 1;
	while(b)
	{
		if(b&1)r = a*r;
		a = a*a;
		b>>=1;
	}
	return r;
}
il ll gcd(ll a,ll b)
{
	while(b ^= a ^= b ^= a %= b);
	return a;
}
il ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
il ll inv(ll a,ll p)
{
	return qpow(a,p-2);
}
int main()
{
	int T = read();
	while(T--)
	{
		int a[5];
		int ans = 0;
		for(int i = 1; i <= 3; i++)
			a[i] = read();
		sort(a+1,a+4);
		if(a[1])
		{
			{
				a[1]--,a[2]--,a[3]--;
				ans += 3;
			}
			if(a[2] && a[3])
				a[2]--,a[3]--,ans++;
			if(a[1] && a[3])
				a[3]--,a[1]--,ans++;
			if(a[2] && a[1])
				a[2]--,a[1]--,ans++;
			if(a[1] && a[2] && a[3])
				ans++;
		}
		else if(a[2])
		{
			if(a[2] == 1)
			{
				ans += 2,a[2]--,a[3]--;
				if(a[3] && a[2])
					ans += 1;
			}
			else
				ans = 3;
		}
		else if(a[3])
			ans = 1;
		printf("%d\n",ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define inf 0x3f3f3f3f
#define INF 0xffffffff
#define il inline
#define pb push_back
#define db double
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define fi first
#define se second
const int mod = 1e9+7;
il ll read()
{
	char ch = getchar();
	ll p = 1,data = 0;
	while(ch<'0'||ch>'9')
	{
		if(ch == '-')p = -1;
		ch = getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		data = (data<<3)+(data<<1)+(ch^48);
		ch = getchar();
	}
	return p*data;
}
il ll lowbit(ll a)
{
	return a&(-a);
}
il ll qpow(ll a,ll b)
{
	ll r = 1;
	while(b)
	{
		if(b&1)r = a*r;
		a = a*a;
		b>>=1;
	}
	return r;
}
il ll gcd(ll a,ll b)
{
	while(b ^= a ^= b ^= a %= b);
	return a;
}
il ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
il ll inv(ll a,ll p)
{
	return qpow(a,p-2);
}
int main()
{
	int T = read();
	while(T--)
	{
		int a[4];
		int ans = 0;
		for(int i = 1; i <= 3; i++)
			a[i] = read();
		sort(a+1,a+4);
		if(a[1] >= 4 && a[2] >= 4 && a[3] >= 4)
			puts("7");
		else
		{
			if(a[1])
			{
				a[1]--,a[2]--,a[3]--;
				ans += 3;
			}
			if(a[1] && a[3])
				a[1]--,a[3]--,ans++;
			if(a[2] && a[3])
				a[3]--,a[2]--,ans++;
			if(a[2] && a[1])
				a[2]--,a[1]--,ans++;
			if(a[1] && a[2] && a[3])
				ans++;
			printf("%d\n",ans);
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define inf 0x3f3f3f3f
#define INF 0xffffffff
#define il inline
#define pb push_back
#define db double
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define fi first
#define se second
const int mod = 1e9+7;
il ll read()
{
	char ch = getchar();
	ll p = 1,data = 0;
	while(ch<'0'||ch>'9')
	{
		if(ch == '-')p = -1;
		ch = getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		data = (data<<3)+(data<<1)+(ch^48);
		ch = getchar();
	}
	return p*data;
}
il ll lowbit(ll a)
{
	return a&(-a);
}
il ll qpow(ll a,ll b)
{
	ll r = 1;
	while(b)
	{
		if(b&1)r = a*r;
		a = a*a;
		b>>=1;
	}
	return r;
}
il ll gcd(ll a,ll b)
{
	while(b ^= a ^= b ^= a %= b);
	return a;
}
il ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
il ll inv(ll a,ll p)
{
	return qpow(a,p-2);
}
int main()
{
	int T = read();
	while(T--)
	{
		int a[4];
		int ans = 0;
		for(int i = 1; i <= 3; i++)
			a[i] = read();
		sort(a+1,a+4);
		if(a[1] >= 4 && a[2] >= 4 && a[3] >= 4)
			puts("7");
		else
		{
			if(a[1])
			{
				a[1]--,a[2]--,a[3]--;
				ans += 3;
			}
			if(a[2] && a[3])
				a[2]--,a[3]--,ans++;
			if(a[1] && a[3])
				a[3]--,a[1]--,ans++;
			if(a[2] && a[1])
				a[2]--,a[1]--,ans++;
			if(a[1] && a[2] && a[3])
				ans++;
			printf("%d\n",ans);
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define inf 0x3f3f3f3f
#define INF 0xffffffff
#define il inline
#define pb push_back
#define db double
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define fi first
#define se second
const int mod = 1e9+7;
il ll read()
{
	char ch = getchar();
	ll p = 1,data = 0;
	while(ch<'0'||ch>'9')
	{
		if(ch == '-')p = -1;
		ch = getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		data = (data<<3)+(data<<1)+(ch^48);
		ch = getchar();
	}
	return p*data;
}
il ll lowbit(ll a)
{
	return a&(-a);
}
il ll qpow(ll a,ll b)
{
	ll r = 1;
	while(b)
	{
		if(b&1)r = a*r;
		a = a*a;
		b>>=1;
	}
	return r;
}
il ll gcd(ll a,ll b)
{
	while(b ^= a ^= b ^= a %= b);
	return a;
}
il ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
il ll inv(ll a,ll p)
{
	return qpow(a,p-2);
}
int main()
{
	int T = read();
	while(T--)
	{
		int a[4];
		int ans = 0;
		for(int i = 1; i <= 3; i++)
			a[i] = read();
		sort(a+1,a+4);
		if(a[1] >= 4 && a[2] >= 4 && a[3] >= 4)
			puts("7");
		else
		{
			if(a[1])
			{
				a[1]--,a[2]--,a[3]--;
				ans += 3;
			}
			if(a[3])
			{
				if(a[2])
					a[2]--,a[3]--,ans++;
				if(a[3] && a[1])
					a[2]--,a[1]--,ans++;
			}
			if(a[2] && a[1])
				a[2]--,a[1]--,ans++;
			if(a[1] && a[2] && a[3])
				ans++;
			printf("%d\n",ans);
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int T;
    cin >> T;
    while(T--){
        int a, b, c;
        cin >> a >> b >> c;
        int ans = 0;
        if(a) ans++, a--;
        if(b) ans++, b--;
        if(c) ans++, c--;

        if(a < b) swap(a, b);
        if(a < c) swap(a, c);
        if(a && b) ans++, a--, b--;
        if(a && c) ans++, c--, a--;
        if(b && c) ans++, b--, c--;
        if(a&&b&&c) ans++;
        cout << ans << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int T;
    cin >> T;
    while(T--){
        int a, b, c;
        cin >> a >> b >> c;
        int ans = 0;
        if(a) ans++, a--;
        if(b) ans++, b--;
        if(c) ans++, c--;
        if(a < b) swap(a, b);
        if(a < c) swap(a, c);
        if(a && b) ans++, a--, b--;
        if(a && c) ans++, c--, a--;
        if(b && c) ans++, c--, b--;
        if(a&b&c) ans++;
        cout << ans << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int T;
    cin >> T;
    while(T--){
        int a, b, c;
        cin >> a >> b >> c;
        int ans = 0;
        if(a) ans++, a--;
        if(b) ans++, b--;
        if(c) ans++, c--;
        if(a < b) swap(a, b);
        if(a < c) swap(a, c);
        if(a && b) ans++, a--, b--;
        if(a && c) ans++, c--, a--;
        if(b && c) ans++, b--, c--;
        if(a&&b&&c) ans++;
        cout << ans << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    scanf("%d", &t);
    while(t--) {
        int a, b, c, ans = 0;
        scanf("%d%d%d", &a, &b, &c);
        if(a) ans++;
        if(b) ans++;
        if(c) ans++;
        if(ans == 0) printf("0\n");
        else if(ans == 1) printf("1\n");
        else if(ans == 2) {
            if(a == 1 || b == 1 || c == 1) printf("2\n");
            else printf("3\n");
        }
        else {
            ans = 0;
            if(a == 1) ans++;
            if(b == 1) ans++;
            if(c == 1) ans++;
            if(ans == 0) {
                ans = 0;
                if(a == 2) ans++;
                if(b == 2) ans++;
                if(c == 2) ans++;
                if(ans == 0) {
                    if(a == 3 || b == 3 || c == 3) printf("6\n");
                    else printf("7\n");
                }
                else if(ans == 1 || ans == 2) printf("5\n");
                else if(ans == 3) printf("4\n");
            }
            else if(ans == 1) printf("4\n");
            else if(ans >= 2) printf("3\n");
        }
    }
    return 0;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
#define ll long long
#define fi first
#define se second
#define re register
#define pb push_back
#define mp make_pair
const int N=1e6+10;
const int mod=1e9+7;
const double pi=3.1415926535898;
const double eps=1e-11;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int a[5];
int main()
{
    int T;
    read(T);
    while(T--)
    {
        for(re int i=1;i<=3;i++) read(a[i]);
        sort(a+1,a+4);
        int ans=0;
        for(re int i=1;i<=3;i++) if(a[i]) ans++,a[i]--;
        if(a[1])
        {
            int t=min(a[1],3);
            if(t==3) a[2]-=2,a[3]-=2,ans+=3;
            else if(t==2)
            {
                a[2]--,a[3]--;
                ans+=2;
            }
            else if(t==1) a[3]--,ans++;
        }
        sort(a+1,a+4);
        if(a[2]) ans+=min(a[2],1);
        printf("%d\n",ans);
    }
    return 0;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
#define ll long long
#define fi first
#define se second
#define re register
#define pb push_back
#define mp make_pair
const int N=1e6+10;
const int mod=1e9+7;
const double pi=3.1415926535898;
const double eps=1e-11;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int a[5];
int main()
{
    int T;
    read(T);
    while(T--)
    {
        for(re int i=1;i<=3;i++) read(a[i]);
        sort(a+1,a+4);
        int ans=0;
        for(re int i=1;i<=3;i++) if(a[i]) ans++,a[i]--;
        if(a[1]) ans+=min(a[1],3);
        if(a[2]) ans+=min(a[2],1);
        printf("%d\n",ans);
    }
    return 0;
}


int t;
    scanf("%d", &t);
    while(t--) {
        int a, b, c, ans = 0;
        scanf("%d%d%d", &a, &b, &c);
        if(a) ans++;
        if(b) ans++;
        if(c) ans++;
        if(ans == 0) printf("0\n");
        else if(ans == 1) printf("1\n");
        else if(ans == 2) {
            if(a == 1 || b == 1 || c == 1) printf("2\n");
            else printf("3\n");
        }
        else {
            ans = 0;
            if(a == 1) ans++;
            if(b == 1) ans++;
            if(c == 1) ans++;
            if(ans == 0) {
                ans = 0;
                if(a == 2) ans++;
                if(b == 2) ans++;
                if(c == 2) ans++;
                if(ans == 0) {
                    if(a == 3 || b == 3 || c == 3) printf("6\n");
                    else printf("7\n");
                }
                else if(ans == 1 || ans == 2) printf("5\n");
                else if(ans == 3) printf("4\n");
            }
            else if(ans == 1) printf("4\n");
            else if(ans >= 2) printf("3\n");
        }
    }
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
bool comp(int x,int y){
     return (x>y);
}
int main(){
    int T;
    cin>>T;
    while(T--){
         int a[4];
         cin>>a[1]>>a[2]>>a[3];
         sort(a +1,a+4,comp);
         int count = 0;
         for(int i =1;i<4;i++){
              if(a[i]>0){
                   a[i]--;
                   count++;
              }
         }
         for(int i =1;i<4;i++){
              {
                   if(i<3){
                   for(int j=i+1;j<4;j++){
                   if(a[i]>0 && a[j]>0){
                        a[i]--;
                        a[j]--;
                        count++;
                   }
              }

              }else if(a[1]>0 && a[2]>0 && a[3]>0){
                   count++;
              }
         }
    }
    cout<<count<<endl;
}
}


#include<iostream>
#include<algorithm>
using namespace std;
bool comp(int x,int y){
     return (x>y);
}
int main(){
    int T;
    cin>>T;
    while(T--){
         int a[4];
         cin>>a[1]>>a[2]>>a[3];
         sort(a +1,a+4,comp);
         int count = 0;
         for(int i =1;i<4;i++){
              if(a[i]>0){
                   a[i]--;
                   count++;
              }
         }
         for(int i =1;i<4;i++){
              {
                   if(i<3){
                   for(int j=i+1;j<4;j++){
                   if(a[i]>0 && a[j]>0){
                        a[i]--;
                        a[j]--;
                        count++;
                   }
              }

              }else if(a[1]>0 && a[2]>0 && a[3]>0){
                   count++;
              }
         }
    }
    cout<<count<<endl;
}


#include<iostream>
#include<algorithm>
using namespace std;
bool comp(int x,int y){
     return (x>y);
}
int main(){
    int T;
    cin>>T;
    while(T--){
         int a[4];
         cin>>a[1]>>a[2]>>a[3];
         sort(a +1,a+4,comp);
         int count = 0;
         for(int i =1;i<4;i++){
              if(a[i]>0){
                   a[i]--;
                   count++;
              }
         }
         for(int i =1;i<4;i++){
              {
                   if(i<3){
                   for(int j=i+1;j<4){
                   if(a[i]>0 && a[j]>0){
                        a[i]--;
                        a[j]--;
                        count++;
                   }
              }

              }else if(a[1]>0 && a[2]>0 && a[3]>0){
                   count++;
              }
         }
    }
    cout<<count<<endl;
}


#include<iostream>
#include<algorithm>
using namespace std;
bool comp(int x,int y){
     if(x>y) return true;
     else return false;
}
int main(){
     int t;
     cin>>t;
     while(t--){
          int a[3],count =0;
          for(int i=0;i<3;i++){
               cin>>a[i];
          }
          sort(a,a+3,comp);

          for(int i =0;i<3;i++){
               if(a[i]>0){
                    a[i]--;
                    count++;
               }
          }
          for(int i=0;i<2;i++){
               for(int j =i+1;j<3;j++){
                    if(a[i]>0 && a[j]>0){
                         a[i]--;
                         a[j]--;
                         count++;
                    }
               }
          }
          bool flag = true;
          for(int i =0;i<3;i++){
               if(a[i] == 0){
                    flag = false;
               }
          }
          if(flag) count++;
          cout<<count<<endl;
     }
}


#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a[3];
        cin>>a[0]>>a[1]>>a[2];
        int ans=0;
        int count=0;
        for(int i=0;i<3;i++)
        {
            if(a[i]>0)
            {
                count++;
                a[i]--;

            }
        }
        ans=ans+count;
        if(count<3)
        {
            cout<<ans<<endl;
            continue;
        }
        int count0=0;
        int count1=0;
        int count2=0;
        int count3=0;
        for(int i=0;i<3;i++)
        {
            if(a[i]==0)
            {
                count0++;
            }
            if(a[i]==1)
            {
                count1++;
            }
            if(a[i]==2)
            {
                count2++;
            }
            else
            {
                count3++;
            }

        }
        if(count0>0)
        {
            if(count0==1)
            {
                cout<<"4"<<endl;
            }
            else if(count0>=2)
            {
                cout<<"3"<<endl;
            }

        }
        else
        {

            if(count1==0)
            {
                if(count3==3)
                {
                    cout<<"7"<<endl;
                }
                else
                    cout<<"6"<<endl;
            }
            else
            {

                if(count1==3)
                {
                    cout<<"4"<<endl;
                }
                else if(count1==2)
                {
                    cout<<"5"<<endl;
                }
                else if(count1==1)
                {
                    cout<<"5"<<endl;
                }
            }

        }

        }
    }


#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a[3];
        int b[3];
        cin>>a[0]>>a[1]>>a[2];

        int ans=0;
        int count=0;
        for(int i=0;i<3;i++)
        {
            if(a[i]>0)
            {
                count++;
                a[i]--;

            }
        }
        ans=ans+count;
        if(count<3)
        {

            if(count==1||count==0)
            cout<<ans<<endl;
            else
            {

                int count1=0;
                for(int i=0;i<3;i++)
                {
                    if(a[i]>0)
                    {
                        count1++;
                    }
                }
                if(count1==1)
                {
                    cout<<ans<<endl;
                }
                else if(count1==2)
                {
                    cout<<ans+1<<endl;
                }
                else
                    cout<<ans<<endl;

            }

            continue;
        }
        int count0=0;
        int count1=0;
        int count2=0;
        int count3=0;
        for(int i=0;i<3;i++)
        {
            if(a[i]==0)
            {
                count0++;
            }
            if(a[i]==1)
            {
                count1++;
            }
            if(a[i]==2)
            {
                count2++;
            }
            else
            {
                count3++;
            }

        }
        if(count0>0)
        {
            if(count0==1)
            {
                cout<<"4"<<endl;
            }
            else if(count0>=2)
            {
                cout<<"3"<<endl;
            }

        }
        else
        {

            if(count1==0)
            {
                if(count3==3)
                {
                    cout<<"7"<<endl;
                }
                else
                    cout<<"6"<<endl;
            }
            else
            {

                if(count1==3)
                {
                    cout<<"4"<<endl;
                }
                else if(count1==2)
                {
                    cout<<"5"<<endl;
                }
                else if(count1==1)
                {
                    cout<<"5"<<endl;
                }
            }

        }

        }
    }


#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a[3];
        cin>>a[0]>>a[1]>>a[2];
        int ans=0;
        int count=0;
        for(int i=0;i<3;i++)
        {
            if(a[i]>0)
            {
                count++;
                a[i]--;

            }
        }
        ans=ans+count;
        if(count<3)
        {
            cout<<ans<<endl;
            continue;
        }
        count=0;
        for(int i=0;i<3;i++)
        {
            if(a[i]==0)
            {
                count++;
            }

        }
        if(count!=0)
        {

            if(count==1)
            {
                cout<<ans+1<<endl;

            }
            else
            {
                cout<<ans<<endl;
            }

        }
        else
        {
            if(a[0]==1&&a[1]==1&&a[2]==1)
            {
                cout<<ans+1<<endl;
            }
            else
            {
                if(a[0]>=3&&a[1]>=3&&a[2]>=3)
                {
                    cout<<"7"<<endl;
                }
                else
                {
                    int count1=0;
                    int count2=0;
                    int count3=0;
                    for(int i=0;i<3;i++)
                    {
                        if(a[i]==1)
                        {
                            count1++;
                        }
                        if(a[i]==2)
                        {
                            count2++;
                        }
                        else
                        {
                            count3++;
                        }

                    }
                    if(count1==1)
                    {
                        cout<<"5"<<endl;
                    }
                    if(count1==2)
                    {
                        cout<<"5"<<endl;
                    }
                    if(count1==0)
                    {
                        cout<<"6"<<endl;
                    }

                }
            }

        }
    }
}


#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a[3];
        cin>>a[0]>>a[1]>>a[2];
        int ans=0;
        int count=0;
        for(int i=0;i<3;i++)
        {
            if(a[i]>0)
            {
                count++;
                a[i]--;

            }
        }
        ans=ans+count;
        if(count<3)
        {

            if(count==1||count==0)
            cout<<ans<<endl;
            else
            {

                int count1=0;
                int count2=0;
                int count3=0;
                for(int i=0;i<3;i++)
                {
                    if(a[i]==1)
                    {
                        count1++;
                    }
                    if(a[i]==2)
                    {
                        count2++;
                    }
                    else
                        count3++;

                }
                if(count1==1)
                {
                    cout<<ans<<endl;
                }
                else if(count1==0)
                {
                    cout<<ans+1<<endl;
                }

            }

            continue;
        }
        int count0=0;
        int count1=0;
        int count2=0;
        int count3=0;
        for(int i=0;i<3;i++)
        {
            if(a[i]==0)
            {
                count0++;
            }
            if(a[i]==1)
            {
                count1++;
            }
            if(a[i]==2)
            {
                count2++;
            }
            else
            {
                count3++;
            }

        }
        if(count0>0)
        {
            if(count0==1)
            {
                cout<<"4"<<endl;
            }
            else if(count0>=2)
            {
                cout<<"3"<<endl;
            }

        }
        else
        {

            if(count1==0)
            {
                if(count3==3)
                {
                    cout<<"7"<<endl;
                }
                else
                    cout<<"6"<<endl;
            }
            else
            {

                if(count1==3)
                {
                    cout<<"4"<<endl;
                }
                else if(count1==2)
                {
                    cout<<"5"<<endl;
                }
                else if(count1==1)
                {
                    cout<<"5"<<endl;
                }
            }

        }

        }
    }


#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a[3];
        int b[3];
        cin>>a[0]>>a[1]>>a[2];

        int ans=0;
        int count=0;
        for(int i=0;i<3;i++)
        {
            if(a[i]>0)
            {
                count++;
                a[i]--;

            }
        }
        ans=ans+count;
        if(count<3)
        {

            if(count==1||count==0)
            cout<<ans<<endl;
            else
            {

                int count1=0;
                for(int i=0;i<3;i++)
                {
                    if(a[i]>0)
                    {
                        count1++;
                    }
                }
                if(count1==1)
                {
                    cout<<ans<<endl;
                }
                else if(count1==2)
                {
                    cout<<ans+1<<endl;
                }

            }

            continue;
        }
        int count0=0;
        int count1=0;
        int count2=0;
        int count3=0;
        for(int i=0;i<3;i++)
        {
            if(a[i]==0)
            {
                count0++;
            }
            if(a[i]==1)
            {
                count1++;
            }
            if(a[i]==2)
            {
                count2++;
            }
            else
            {
                count3++;
            }

        }
        if(count0>0)
        {
            if(count0==1)
            {
                cout<<"4"<<endl;
            }
            else if(count0>=2)
            {
                cout<<"3"<<endl;
            }

        }
        else
        {

            if(count1==0)
            {
                if(count3==3)
                {
                    cout<<"7"<<endl;
                }
                else
                    cout<<"6"<<endl;
            }
            else
            {

                if(count1==3)
                {
                    cout<<"4"<<endl;
                }
                else if(count1==2)
                {
                    cout<<"5"<<endl;
                }
                else if(count1==1)
                {
                    cout<<"5"<<endl;
                }
            }

        }

        }
    }


#include <bits/stdc++.h>
using namespace std;
void solve(int a,int b,int c)
{
	int minn,maxx,tmp;
	minn = maxx = a;
	if(b < minn)
	minn = b;
	if(c < minn)
	minn = c;
	if(b > maxx)
	maxx = b;
	if(c > maxx)
	maxx = c;
	tmp = a + b + c - minn - maxx;
	a = minn,b = tmp,c = maxx;
	if(a >= 4)
	printf("7\n");
	else if(a >= 3 &&c <= 4)
	printf("6\n");
	else if(a >= 2&& c > 2)
	printf("5\n");
	else if(a >= 1 && b > 1)
	printf("4\n");
	else if(a == 1 && b == 1 && c == 2)
	printf("3\n");
	else
	printf("%d\n",a+b+c);
}
int main()
{
	int t;
	int a,b,c;
	int tmp;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d",&a,&b,&c);
		solve(a,b,c);
	}
}


#include <bits/stdc++.h>
using namespace std;
void solve(int a,int b,int c)
{
	int minn,maxx,tmp;
	minn = maxx = a;
	if(b < minn)
	minn = b;
	if(c < minn)
	minn = c;
	if(b > maxx)
	maxx = b;
	if(c > maxx)
	maxx = c;
	tmp = a + b + c - minn - maxx;
	a = minn,b = tmp,c = maxx;
	if(a >= 4 && b >= 4 && c >= 4)
	printf("7\n");
	else if(a >= 3 && b >= 3 && c >= 3)
	printf("6\n");
	else if(a >= 2 && b >= 2 && c >= 3)
	printf("5\n");
	else if(a >= 1 && b >= 2 && c >= 2)
	printf("4\n");
	else if(a == 1 && b == 1 && c == 2)
	printf("3\n");
	else
	printf("%d\n",a+b+c);
}
int main()
{
	int t;
	int a,b,c;
	int tmp;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d",&a,&b,&c);
		solve(a,b,c);
	}
}


#include <bits/stdc++.h>
using namespace std;
void solve(int a,int b,int c)
{
	int minn,maxx,tmp;
	minn = maxx = a;
	if(b < minn)
	minn = b;
	if(c < minn)
	minn = c;
	if(b > maxx)
	maxx = b;
	if(c > maxx)
	maxx = c;
	tmp = a + b + c - minn - maxx;
	a = minn,b = tmp,c = maxx;
	if(a >= 4)
	printf("7\n");
	else if(a >= 3 &&c <= 4)
	printf("6\n");
	else if(a >= 2&& c == 3)
	printf("5\n");
	else if(a >= 1 && c == 2)
	printf("4\n");
	else
	printf("%d\n",a+b+c);
}
int main()
{
	int t;
	int a,b,c;
	int tmp;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d",&a,&b,&c);
		solve(a,b,c);
	}
}


#include <bits/stdc++.h>
using namespace std;
void solve(int a,int b,int c)
{
	int minn,maxx,tmp;
	minn = maxx = a;
	if(b < minn)
	minn = b;
	if(c < minn)
	minn = c;
	if(b > maxx)
	maxx = b;
	if(c > maxx)
	maxx = c;
	tmp = a + b + c - minn - maxx;
	a = minn,b = tmp,c = maxx;
	if(a >= 4 && b >= 4 && c >= 4)
	printf("7\n");
	else if(a >= 3 && b >= 3 && c >= 3)
	printf("6\n");
	else if(a >= 2 && b >= 2 && c >= 3)
	printf("5\n");
	else if(a >= 1 && b >= 2 && c >= 2)
	printf("4\n");
	else
	printf("%d\n",a+b+c);
}
int main()
{
	int t;
	int a,b,c;
	int tmp;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d",&a,&b,&c);
		solve(a,b,c);
	}
}


#include <bits/stdc++.h>
using namespace std;
void solve(int a,int b,int c)
{
	int minn,maxx,tmp;
	minn = maxx = a;
	if(b < minn)
	minn = b;
	if(c < minn)
	minn = c;
	if(b > maxx)
	maxx = b;
	if(c > maxx)
	maxx = c;
	tmp = a + b + c - minn - maxx;
	a = minn,b = tmp,c = maxx;
	if(a >= 4)
	printf("7\n");
	else if(a >= 3 &&c <= 4)
	printf("6\n");
	else if(a >= 2&& c > 2)
	printf("5\n");
	else if(a >= 1 && c > 1)
	printf("4\n");
	else
	printf("%d\n",a+b+c);
}
int main()
{
	int t;
	int a,b,c;
	int tmp;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d",&a,&b,&c);
		solve(a,b,c);
	}
}


#include <bits/stdc++.h>
int judge(int x,int y,int z)
{
	if(x == 0 && y == 0 && z == 0)
	return 0;
	else if(x == 0 && y == 0)
	return 1;
	else if(x == 0 && y == 1)
	return 2;
	else if(x == 0)
	return 3;
	else if(x == 1 && y == 1)
	return 3;

}
void solve(int a,int b,int c)
{
	int minn,maxx,tmp;
	minn = maxx = a;
	if(b < minn)
	minn = b;
	if(c < minn)
	minn = c;
	if(b > maxx)
	maxx = b;
	if(c > maxx)
	maxx = c;
	tmp = a + b + c - minn - maxx;
	a = minn,b = tmp,c = maxx;
	if(a >= 4)
	printf("7\n");
	else if(a >= 3)
	printf("6\n");
	else if(a >= 2&& c > 2)
	printf("5\n");
	else if(a >= 1 && b > 1)
	printf("4\n");
	else
	printf("%d\n",judge(a,b,c));
}
int main()
{
	int t;
	int a,b,c;
	int tmp;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d",&a,&b,&c);
		solve(a,b,c);
	}
}


//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define fori for(int i=0;i<3;i++)
int main(){
	int t,a[3];
	cin>>t;
	while(t--){
		int sum=0;
		fori cin>>a[i];
		sort(a,a+3);
		if(a[0]>=4)cout<<7<<endl;
		else{
			fori{
				if(a[i]){
					sum++;
					a[i]-=1;
				}
			}
			if(a[0]){
				sum++;
				a[0]--;
				a[2]--;
			}
			if(a[0]&&a[2]){
				sum++;
				a[0]--;
				a[2]--;
			}
			if(a[1]&&a[2]){
				sum++;
				a[2]--;
				a[1]--;
			}
			if(a[1]&&a[2]&&a[0]){
				sum++;
			}
			cout<<sum<<endl;
		}
	}
	return 0;
}


//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define fori for(int i=0;i<3;i++)
int main(){
	int t,a[3];
	cin>>t;
	while(t--){
		int sum=0;
		for(int i=0;i<3;i++)cin>>a[i];
		sort(a,a+3);
		if(a[0]>=4)cout<<7<<endl;
		else{
			for(int i=0;i<3;i++){
				if(a[i]){
					sum++;
					a[i]-=1;
				}
			}
			if(a[0]){
				sum++;
				a[0]--;
				a[2]--;
			}
			if(a[0]&&a[1]){
				sum++;
				a[0]--;
				a[1]--;
			}
			if(a[1]&&a[2]){
				sum++;
				a[2]--;
				a[1]--;
			}
			if(a[1]&&a[2]&&a[0]){
				sum++;
			}
			cout<<sum<<endl;
		}
	}
	return 0;
}


//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define fori for(int i=0;i<3;i++)
int t,a[3];
int main(){
	cin>>t;
	while(t--){
		int sum=0;
		fori cin>>a[i];
		sort(a,a+3);
		if(a[0]>=4)cout<<7<<endl;
		else{
			fori{
				if(a[i]){
					sum++;
					a[i]-=1;
				}
			}
			if(a[0]){
				sum++;
				a[0]--;
				a[2]--;
			}
			if(a[1]&&a[2]){
				sum++;
				a[1]--;
				a[2]--;
			}
			if(a[2]&&a[3]){
				sum++;
				a[2]--;
				a[3]--;
			}
			if(a[1]&&a[2]&&a[3]){
				sum++;
			}
			cout<<sum<<endl;
		}
	}
	return 0;
}


//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define fori for(int i=0;i<3;i++)
int main(){
	int t,a[3];
	cin>>t;
	while(t--){
		int sum=0;
		fori cin>>a[i];
		sort(a,a+3);
		if(a[0]>=4)cout<<7<<endl;
		else{
			fori{
				if(a[i]){
					sum++;
					a[i]-=1;
				}
			}
			if(a[0]){
				sum++;
				a[0]--;
				a[2]--;
			}
			if(a[0]&&a[2]){
				sum++;
				a[1]--;
				a[2]--;
			}
			if(a[1]&&a[2]){
				sum++;
				a[2]--;
				a[3]--;
			}
			if(a[1]&&a[2]&&a[0]){
				sum++;
			}
			cout<<sum<<endl;
		}
	}
	return 0;
}


//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define fori for(int i=0;i<3;i++)
int main(){
	int t,a[3];
	cin>>t;
	while(t--){
		int sum=0;
		fori cin>>a[i];
		sort(a,a+3);
		if(a[0]>=4)cout<<7<<endl;
		else{
			fori{
				if(a[i]){
					sum++;
					a[i]-=1;
				}
			}
			if(a[0]){
				sum++;
				a[0]--;
				a[2]--;
			}
			if(a[1]&&a[2]){
				sum++;
				a[1]--;
				a[2]--;
			}
			if(a[2]&&a[3]){
				sum++;
				a[2]--;
				a[3]--;
			}
			if(a[1]&&a[2]&&a[3]){
				sum++;
			}
			cout<<sum<<endl;
		}
	}
	return 0;
}


//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define fori for(int i=0;i<3;i++)
int t,a[3];
int main(){
	cin>>t;
	while(t--){
		fori{
			cin>>a[i];
			a[i]-=1;
		}
		sort(a,a+3);
		if(a[0]>=3){
			cout<<7<<endl;
		}
		else if(a[0]>=2){
			cout<<6<<endl;
		}
		else if(a[0]==1&&a[2]>1){
			cout<<5<<endl;
		}
		else if(a[0]==1&&a[2]==1){
			cout<<4<<endl;
		}
		else if(a[0]==0&&a[1]>0){
			cout<<4<<endl;
		}
		else if(a[0]==0&&a[1]==0){
			cout<<3<<endl;
		}
		else if(a[0]==-1&&a[1]>0){
			cout<<3<<endl;
		}
		else if(a[0]==-1&&a[1]==0){
			cout<<2<<endl;
		}
		else if(a[0]==-1&&a[2]>0){
			cout<<1<<endl;
		}
		else cout<<0<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
       int t;
       cin>>t;
       while(t--)
       {int a,b,c;
       cin>>a>>b>>c;
       int ans=0;
       if(a>0)
        {ans++;
        a--;}
       if(b>0)
       {
              ans++;
              b--;
       }
       if(c>0)
       {
              ans++;
              c--;
       }
       if(a==b&&b==c)
       { ans+=a;
        cout<<ans<<endl;
       }
       if(a==0||b==0||c==0)
       {
              if(a==0&&b>0&&c>0)
               ans+=1;
              if(b==0&&a>0&&c>0)
               ans+=1;
              if(c==0&&b>0&&a>0)
               ans+=1;
               cout<<ans<<endl;
       }
       else
       {
              int least=min(a,b);
              least=min(least,c)+1;
              ans+=least;
              cout<<ans<<endl;
       }

       }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
       int t;
       cin>>t;
       while(t--)
       {int a,b,c;
       cin>>a>>b>>c;
       int ans=0;
       if(a>0)
        {ans++;
        a--;}
       if(b>0)
       {
              ans++;
              b--;
       }
       if(c>0)
       {
              ans++;
              c--;
       }
       if(a==0||b==0||c==0)
       {
        cout<<ans<<endl;
       }
       else
       {
              int least=min(a,b);
              least=min(least,c)+1;
              ans+=least;
              cout<<ans<<endl;
       }

       }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
       int t;
       cin>>t;
       while(t--)
       {int a,b,c;
       cin>>a>>b>>c;
       int ans=0;
       if(a>0)
        {ans++;
        a--;}
       if(b>0)
       {
              ans++;
              b--;
       }
       if(c>0)
       {
              ans++;
              c--;
       }
       if(a==b&&b==c)
       { ans+=a;
        cout<<ans<<endl;
       }
       else
        if(a==0||b==0||c==0)
       {
              if(a==0&&b>0&&c>0)
               ans+=1;
              if(b==0&&a>0&&c>0)
               ans+=1;
              if(c==0&&b>0&&a>0)
               ans+=1;
               cout<<ans<<endl;
       }
       else
       {
              int least=min(a,b);
              least=min(least,c)+1;
              ans+=least;
              cout<<ans<<endl;
       }

       }
}


#include<bits/stdc++.h>
using namespace std;
int call(int a,int b,int c)
{ int ans=0;
       if(a>0)
        {ans++;
        a--;}
       if(b>0)
       {
              ans++;
              b--;
       }
       if(c>0)
       {
              ans++;
              c--;
       }
       if(a>0&&b>0)
       {
              ans++;
              a--;
              b--;
       }
       if(b>0&&c>0)
       {
              ans++;
              b--;
              c--;
       }
       if(a>0&&c>0)
       {
              a--;
              c--;
              ans++;
       }
       if(a>0&&b>0&&c>0)
       {
              ans++;
       }
       return ans;
}
int main()
{
       int t;
       cin>>t;
       while(t--)
       {int a,b,c;
       cin>>a>>b>>c;
       int ans=0;
       ans=max(ans,call(a,b,c));
       ans=max(ans,call(a,c,b));
       ans=max(ans,call(b,a,c));
       ans=max(ans,call(b,c,a));
       ans=max(ans,call(c,a,b));
       ans=max(ans,call(c,b,a));
       cout<<ans<<endl;

       }
}


#include<bits/stdc++.h>
using namespace std;
int call(int a,int b,int c)
{ int ans=0;
       if(a>0)
        {ans++;
        a--;}
       if(b>0)
       {
              ans++;
              b--;
       }
       if(c>0)
       {
              ans++;
              c--;
       }
       if(a>0&&b>0)
       {
              ans++;
              a--;
              b--;
       }
       if(b>0&&c>0)
       {
              ans++;
              b--;
              c--;
       }
       if(a>0&&c>0)
       {
              a--;
              c--;
              ans++;
       }
       if(a>0&&b>0&&c>0)
       {
              ans++;
       }
       return ans;
}
int main()
{
       int t;
       cin>>t;
       while(t--)
       {int a,b,c;
       cin>>a>>b>>c;
       int ans=0;
       ans=max(ans,call(a,b,c));
       //ans=max(ans,call(a,c,b));
//       ans=max(ans,call(b,a,c));
  //     ans=max(ans,call(b,c,a));
    //   ans=max(ans,call(c,a,b));
      // ans=max(ans,call(c,b,a));
       cout<<ans<<endl;

       }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
       int t;
       cin>>t;
       while(t--)
       {int a,b,c;
       cin>>a>>b>>c;
       int ans=0;
       if(a>0)
        {ans++;
        a--;}
       if(b>0)
       {
              ans++;
              b--;
       }
       if(c>0)
       {
              ans++;
              c--;
       }
       if(a>=3&&b>=3&&c>=3)
        {ans+=4;
        cout<<ans<<endl;}
       else
       if(a==0||b==0||c==0)
       {
              if(a==0&&b>0&&c>0)
               ans+=1;
              if(b==0&&a>0&&c>0)
               ans+=1;
              if(c==0&&b>0&&a>0)
               ans+=1;
              cout<<ans<<endl;
       }
       else
       {
              int least=min(a,b);
              least=min(least,c)+1;
              ans+=least;
              cout<<ans<<endl;
       }
       }
}


#include<bits/stdc++.h>
using namespace std;
int call(int a,int b,int c)
{
       if(a>0)
        {ans++;
        a--;}
       if(b>0)
       {
              ans++;
              b--;
       }
       if(c>0)
       {
              ans++;
              c--;
       }
       if(a>0&&b>0)
       {
              ans++;
              a--;
              b--;
       }
       if(b>0&&c>0)
       {
              ans++;
              b--;
              c--;
       }
       if(a>0&&c>0)
       {
              a--;
              c--;
              ans++;
       }
       if(a>0&&b>0&&c>0)
       {
              ans++;
       }
       return ans;
}
int main()
{
       int t;
       cin>>t;
       while(t--)
       {int a,b,c;
       cin>>a>>b>>c;
       int ans=0;
       ans=max(ans,call(a,b,c));
       ans=max(ans,call(a,c,b));
       ans=max(ans,call(b,a,c));
       ans=max(ans,call(b,c,a));
       ans=max(ans,call(c,a,b));
       ans=max(ans,call(c,b,a));
       cout<<ans<<endl;

       }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
       int t;
       cin>>t;
       while(t--)
       {int a,b,c;
       cin>>a>>b>>c;
       int ans=0;
       if(a>0)
        {ans++;
        a--;}
       if(b>0)
       {
              ans++;
              b--;
       }
       if(c>0)
       {
              ans++;
              c--;
       }
       if(a==b&&b==c)
       { ans+=a;
        cout<<ans<<endl;
       }
       else
       {
              int least=min(a,b);
              least=min(least,c)+1;
              ans+=least;
              cout<<ans<<endl;
       }

       }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
       int t;
       cin>>t;
       while(t--)
       {int a,b,c;
       cin>>a>>b>>c;
       int ans=0;
       if(a>0)
        {ans++;
        a--;}
       if(b>0)
       {
              ans++;
              b--;
       }
       if(c>0)
       {
              ans++;
              c--;
       }
       if(a==0||b==0||c==0)
       {
              if(a==0&&b>0&&c>0)
               ans+=1;
              if(b==0&&a>0&&c>0)
              ans+=1;
              if(c==0&&b>0&&a>0)
               ans+=1;
        cout<<ans<<endl;
       }
       else
       {
              int least=min(a,b);
              least=min(least,c)+1;
              ans+=least;
              cout<<ans<<endl;
       }

       }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
       int t;
       cin>>t;
       while(t--)
       {int a,b,c;
       cin>>a>>b>>c;
       int ans=0;
       if(a>0)
        {ans++;
        a--;}
       if(b>0)
       {
              ans++;
              b--;
       }
       if(c>0)
       {
              ans++;
              c--;
       }
       if(a>=3&&b>=3&&c>=3)
        {ans+=4;
        cout<<ans<<endl;}
       else
       {
              int least=min(a,b);
              least=min(least,c);
              ans+=least;
              cout<<ans<<endl;
       }
       }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
       int t;
       cin>>t;
       while(t--)
       {int a,b,c;
       cin>>a>>b>>c;
       int ans=0;
       if(a>0)
        {ans++;
        a--;}
       if(b>0)
       {
              ans++;
              b--;
       }
       if(c>0)
       {
              ans++;
              c--;
       }

              int least=min(a,b);
              least=min(least,c)+1;
              ans+=least;
              cout<<ans<<endl;

       }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
       int t;
       cin>>t;
       while(t--)
       {int a,b,c;
       cin>>a>>b>>c;
       int ans=0;
       if(a>0)
        {ans++;
        a--;}
       if(b>0)
       {
              ans++;
              b--;
       }
       if(c>0)
       {
              ans++;
              c--;
       }
       if(a==b&&b==c)
       {
        cout<<ans<<endl;
       }
       else
       {
              int least=min(a,b);
              least=min(least,c)+1;
              ans+=least;
              cout<<ans<<endl;
       }

       }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
       int t;
       cin>>t;
       while(t--)
       {int a,b,c;
       cin>>a>>b>>c;
       int ans=0;
       if(a>0)
        {ans++;
        a--;}
       if(b>0)
       {
              ans++;
              b--;
       }
       if(c>0)
       {
              ans++;
              c--;
       }
       if(a>=3&&b>=3&&c>=3)
        {ans+=4;
        cout<<ans<<endl;}
       else
       {
              int least=min(a,b);
              least=min(least,c)+1;
              ans+=least;
              cout<<ans<<endl;
       }
       }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int T;
	cin>>T;
	while(T--){
		int a,b,c,ans=0,res=0;
		cin>>a>>b>>c;
		if(a>3&&b>3&&c>3){cout<<7;return 0;}
		if(a)a--,ans++;
		if(b)b--,ans++;
		if(c)c--,ans++;
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
				for(int k=0;k<2;k++){
					a-=(i+j);
					b-=(i+k);
					c-=(j+k);
					if(a>=0&&b>=0&&c>=0)res=max(res,i+j+k);
					a+=(i+j);
					b+=(i+k);
					c+=(j+k);
				}
		cout<<ans+res<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int T;
	cin>>T;
	while(T--){
		int a,b,c,ans=0,res=0;
		cin>>a>>b>>c;
		if(a>3&&b>3&&c>3){cout<<7<<endl;continue;}
		if(a)a--,ans++;
		if(b)b--,ans++;
		if(c)c--,ans++;
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
				for(int k=0;k<2;k++){
					a-=(i+j);
					b-=(i+k);
					c-=(j+k);
					if(a>=0&&b>=0&&c>=0)res=max(res,i+j+k);
					a+=(i+j);
					b+=(i+k);
					c+=(j+k);
				}
		cout<<ans+res<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int T;
	cin>>T;
	while(T--){
		int a,b,c,ans=0,res=0;
		cin>>a>>b>>c;
		if(a>3&&b>3&&c>3){cout<<7;continue;}
		if(a)a--,ans++;
		if(b)b--,ans++;
		if(c)c--,ans++;
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
				for(int k=0;k<2;k++){
					a-=(i+j);
					b-=(i+k);
					c-=(j+k);
					if(a>=0&&b>=0&&c>=0)res=max(res,i+j+k);
					a+=(i+j);
					b+=(i+k);
					c+=(j+k);
				}
		cout<<ans+res<<endl;
	}
}


// om namashivayah
#include<bits/stdc++.h>
#define M 11
#define int long long
#define mp make_pair
#define pb push_back
using namespace std;
int32_t main()
{
    int t=0;
    cin>>t;
    while(t--)
    {
        int a,b,c=0;
        cin>>a>>b>>c;
        int ans=0;

        if(a)
        {
          a--;
          ans++;
        }

        if(b)
        {
          b--;
          ans++;
        }

        if(c)
        {
          c--;
          ans++;
        }

        if(a>=2 && b>=2 && c>=2)
        {
          ans+=3;
        }
        else if((a>=2 || b>=2 || c>=2)&&(a>0 && b>0 && c>0))
        {
          ans+=2;
          if(a>=2)
            a--;
          else if(b>=2)
            b--;
          else
            c--;
          a--;
          b--;
          c--;
        }
        else
        {
          if(a && b)
          {
            ans++;
            a--;
            b--;
          }
          else if(b&&c)
          {
            ans++;
            b--;
            c--;
          }
          else if(a&&c)
          {
            ans++;
            a--;
            c--;
          }
          else
            int g = 0;
        }

        if(a&&b&&c)
          ans++;
        cout<<ans<<endl;
    }//t ends
    return 0;
}


// om namashivayah
#include<bits/stdc++.h>
#define M 11
#define int long long
#define mp make_pair
#define pb push_back
using namespace std;
int32_t main()
{
    int t=0;
    cin>>t;
    while(t--)
    {
        int a,b,c=0;
        cin>>a>>b>>c;
        int ans=0;

        if(a)
        {
          a--;
          ans++;
        }

        if(b)
        {
          b--;
          ans++;
        }

        if(c)
        {
          c--;
          ans++;
        }

        if(a>=2 && b>=2 && c>=2)
        {
          ans+=3;
          a=a-2;
          b=b-2;
          c=c-2;
        }
        else if((a>=2 || b>=2 || c>=2)&&(a>0 && b>0 && c>0))
        {
          ans+=2;
          if(a>=2)
            a--;
          else if(b>=2)
            b--;
          else
            c--;
          a--;
          b--;
          c--;
        }
        else
        {
          if(a && b)
          {
            ans++;
            a--;
            b--;
          }
          else if(b&&c)
          {
            ans++;
            b--;
            c--;
          }
          else if(a&&c)
          {
            ans++;
            a--;
            c--;
          }
          else
            int g = 0;
        }

        if(a&&b&&c)
          ans++;
        cout<<ans<<endl;
    }//t ends
    return 0;
}


// om namashivayah
#include<bits/stdc++.h>
#define M 11
#define int long long
#define mp make_pair
#define pb push_back
using namespace std;
int32_t main()
{
    int t=0;
    cin>>t;
    while(t--)
    {
        int a,b,c=0;
        cin>>a>>b>>c;
        int ans=0;

        if(a)
        {
          a--;
          ans++;
        }

        if(b)
        {
          b--;
          ans++;
        }

        if(c)
        {
          c--;
          ans++;
        }

        if(a && b)
        {
            a--;
            b--;
            ans++;
        }

        if(b && c)
        {
            b--;
            c--;
            ans++;
        }

        if(a && c)
        {
            a--;
            c--;
            ans++;
        }

        if(a && b && c)
        {
           ans++;
        }
        cout<<ans<<endl;
    }//t ends
    return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
int t, a, b, c;
signed main() {
    cin >> t;
    while(t--) {
       cin >> a >> b >> c;
       if(a > b) swap(a, b);
       if(a > c) swap(a, c);
       if(b > c) swap(b, c);
       int ans = 0;
       if(a > 0) a--, ans++;
       if(b > 0) b--, ans++;
       if(c > 0) c--, ans++;
       if(a > 0 && c > 0) a--, c--, ans++;
       if(a > 0 && b > 0) a--, b--, ans++;
       if(b > 0 && c > 0) b--, c--, ans++;
       if(a > 0 && b > 0 && c > 0) a--, b--, c--, ans++;
       cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MOD     = 1e9+7;
const int INT_INF = 0x3f3f3f3f;
const ll  LL_INF  = 0x3f3f3f3f3f3f3f3f;
const int POS[8]  = {0, 1, 0, -1, 1, 0, 1, -1};
const int MAXM    = 1000005;
const int MAXN    = 100005;

int main()
{

    int T; cin >> T;
    while(T--) {
        int cnt = 0;
        int t[3];
        cin >> t[0] >> t[1] >> t[2];
        sort(t, t+3);
        int a = t[2], b = t[1], c = t[0];
        if(a > 0) cnt ++, a--;
        if(b > 0) cnt ++, b--;
        if(c > 0) cnt ++, c--;
        if(a > 0 && b > 0) cnt ++, a--, b--;
        if(a > 0 && c > 0) cnt ++, a--, c--;
        if(c > 0 && b > 0) cnt ++, c--, b--;
        if(a > 0 && b > 0 && c > 0) cnt ++, a--, b--, c--;

        cout << cnt << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define N 500005
#define M 5005
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int a,b,c;
int p[10][3]={
	1,0,0,
	0,1,0,
	0,0,1,
	1,1,0,
	1,0,1,
	0,1,1,
	1,1,1
};
int count(int s){
	int sum=0;
	for(;s;s>>=1)sum+=(s&1);
	return sum;
}
bool check(int s){
	int x=a,y=b,z=c;
	rep(i,0,6)if(s&(1<<i))
	  x-=p[i][0],
	  y-=p[i][1],
	  z-=p[i][2];
	if(x>=0&&y>=0&&z>=0)return true;
	return false;
}
int work(){
	int ans=0;
	rep(s,0,(1<<7)-1)
	  if(check(s))ans=max(ans,count(s));
	return ans;
}
int main(){
	/*rep(i,0,7){
		rep(j,0,2)printf("%d ",p[i][j]);
		putchar('\n');
	}*/
	int T;scanf("%d",&T);
	while(T--){
		scanf("%d%d%d",&a,&b,&c);
		printf("%d\n",work());
	}
	return 0;
}


#include<bits/stdc++.h>
#define N 500005
#define M 5005
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int a,b,c;
int work(){
	if(a>=4&&b>=4&&c>=4)return 7;
	if(a>=3&&b>=3&&c>=3)return 6;
	int mx=max(c,max(a,b));
	int mn=min(c,min(a,b));
	int sum=a+b+c;
	if(mn>=2&&sum>=7)return 5;
	if(mn>=1&&sum>=5)return 4;
	if(mn>=1)return 3;
	if(mx==1&&sum==2)return 2;
	if(sum)return 1;
	return 0;
}
int main(){
	int T;scanf("%d",&T);
	while(T--){
		scanf("%d%d%d",&a,&b,&c);
		printf("%d\n",work());
	}
	return 0;
}


#include<bits/stdc++.h>
#define N 500005
#define M 5005
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int a,b,c;
int work(){
	if(a>=4&&b>=4&&c>=4)return 7;
	if(a>=3&&b>=3&&c>=3)return 6;
	int mx=max(c,max(a,b));
	int mn=min(c,min(a,b));
	int sum=a+b+c;
	if(mn>=2&&sum>=7)return 5;
	if(mn>=1&&sum>=5)return 4;
	if(mn>=1||(a>1&&b>1)||(a>1&&c>1)||(b>1&&c>1))return 3;
	if((a&&b)||(b&&c)||(c&&a))return 2;
	if(sum)return 1;
	return 0;
}
int main(){
	int T;scanf("%d",&T);
	while(T--){
		scanf("%d%d%d",&a,&b,&c);
		printf("%d\n",work());
	}
	return 0;
}


#include<bits/stdc++.h>
#define N 500005
#define M 5005
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int a,b,c;
int p[10][3]={
	1,0,0,
	0,1,0,
	0,0,1,
	1,1,0,
	1,0,1,
	0,1,1,
	1,1,1
};
int count(int s){
	int sum=0;
	for(;s;s>>=1)sum+=(s&1);
	return sum;
}
bool check(int s){
	int x=a,y=b,z=c;
	rep(i,0,6)if(s&(1<<i))
	  x-=p[i][0],
	  y-=p[i][1],
	  z-=p[i][2];
	if(x>=0&&y>=0&&z>=0)return true;
	return false;
}
int work(){
	int ans=0;
	rep(s,0,(1<<7)-1)
	  if(check(s))ans=max(ans,count(s));
	return ans;
}
/*By Inf_Voltage*/
int main(){
	/*rep(i,0,7){
		rep(j,0,2)printf("%d ",p[i][j]);
		putchar('\n');
	}*/
	int T;scanf("%d",&T);
	while(T--){
		scanf("%d%d%d",&a,&b,&c);
		printf("%d\n",work());
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int T,a,b,c,ans;
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d%d",&a,&b,&c);
		ans=0;
		if(a>0) a--,ans++;
		if(b>0) b--,ans++;
		if(c>0) c--,ans++;
		if(a>=2)
		{
			if(b>0) b--,a--,ans++;
			if(c>0) c--,a--,ans++;
			if(b>0&&c>0) b--,c--,ans++;
		}
		else if(b>=2)
		{
			if(a>0) a--,b--,ans++;
			if(c>0) c--,b--,ans++;
		}
		else if(c>=2)
		{
			if(a>0) a--,c--,ans++;
			if(b>0) b--,c--,ans++;
		}
		else if(a+b+c>=2) ans++;
		if(a>0&&b>0&&c>0) ans++;
		printf("%d\n",ans);
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int T,a,b,c,ans;
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d%d",&a,&b,&c);
		ans=0;
		if(a>0) a--,ans++;
		if(b>0) b--,ans++;
		if(c>0) c--,ans++;
		if(a>=2)
		{
			if(b>0) b--,a--,ans++;
			if(c>0) c--,a--,ans++;
			if(b>0&&c>0) b--,c--,ans++;
		}
		else if(b>=2)
		{
			if(a>0) a--,b--,ans++;
			if(c>0) c--,b--,ans++;
		}
		else if(c>=2)
		{
			if(a>0) a--,c--,ans++;
			if(b>0) b--,c--,ans++;
		}
		if(a>0&&b>0&&c>0) ans++;
		printf("%d\n",ans);
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int T,a,b,c,ans;
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d%d",&a,&b,&c);
		ans=0;
		if(a>0) a--,ans++;
		if(b>0) b--,ans++;
		if(c>0) c--,ans++;
		if(a>=2)
		{
			if(b>0) b--,a--,ans++;
			if(c>0) c--,a--,ans++;
		}
		else if(b>=2)
		{
			if(a>0) a--,b--,ans++;
			if(c>0) c--,b--,ans++;
		}
		else if(c>=2)
		{
			if(a>0) a--,c--,ans++;
			if(b>0) b--,c--,ans++;
		}
		if(a>0&&b>0&&c>0) ans++;
		printf("%d\n",ans);
	}
	return 0;
}


#include<map>
#include<list>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define il inline
#define ll long long
#define rl register ll
#define ri register int
#define rc register char
using namespace std;
il int read(){
	rc c=' ';
	ri v=0,x=1;
	while((c<'0')||(c>'9')){if(c=='-') x=-1;c=getchar();}
	while((c>='0')&&(c<='9')){v=(v<<1)+(v<<3)+(c^48);c=getchar();}
	return v*x;
}
il void write(ri x){
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10^48);
}
int t,a,b,c,ans;
int main(){
	t=read();
	while(t--){
		a=read(),b=read(),c=read();
		ans=0;
		if(a<b) swap(a,b);
		if(a<c) swap(a,c);
		if(b<c) swap(b,c);
		if(a) a--,ans++;
		if(b) b--,ans++;
		if(c) c--,ans++;
		if(a&&b) a--,b--,ans++;
		if(a&&c) a--,c--,ans++;
		if(b&&c) b--,c--,ans++;
		if(a&&b&&c) a--,b--,c--,ans++;
		write(ans),putchar('\n');
	}
	return ~~(0-0);
}


#include<map>
#include<list>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define il inline
#define ll long long
#define rl register ll
#define ri register int
#define rc register char
using namespace std;
il int read(){
	rc c=' ';
	ri v=0,x=1;
	while((c<'0')||(c>'9')){if(c=='-') x=-1;c=getchar();}
	while((c>='0')&&(c<='9')){v=(v<<1)+(v<<3)+(c^48);c=getchar();}
	return v*x;
}
il void write(ri x){
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10^48);
}
int t,a,b,c,ans;
int main(){
	t=read();
	while(t--){
		a=read(),b=read(),c=read();
		ans=0;
		if(a>b) swap(a,b);
		if(a>c) swap(a,c);
		if(b>c) swap(b,c);
		if(a) a--,ans++;
		if(b) b--,ans++;
		if(c) c--,ans++;
		if(a&&b) a--,b--,ans++;
		if(a&&c) a--,c--,ans++;
		if(b&&c) b--,c--,ans++;
		if(a&&b&&c) a--,b--,c--,ans++;
		write(ans),putchar('\n');
	}
	return ~~(0-0);
}


#include<map>
#include<list>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define il inline
#define ll long long
#define rl register ll
#define ri register int
#define rc register char
using namespace std;
il int read(){
	rc c=' ';
	ri v=0,x=1;
	while((c<'0')||(c>'9')){if(c=='-') x=-1;c=getchar();}
	while((c>='0')&&(c<='9')){v=(v<<1)+(v<<3)+(c^48);c=getchar();}
	return v*x;
}
il void write(ri x){
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10^48);
}
int t,a,b,c,cnt1,cnt2,ans;
int main(){
	t=read();
	while(t--){
		a=read(),b=read(),c=read();
		cnt1=cnt2=ans=0;
		if(a) a--,ans++;
		if(b) b--,ans++;
		if(c) c--,ans++;
		if(a&&b) a--,b--,ans++;
		if(a&&c) a--,c--,ans++;
		if(b&&c) b--,c--,ans++;
		if(a&&b&&c) a--,b--,c--,ans++;
		write(ans),putchar('\n');
	}
	return ~~(0-0);
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1014;
int T;
int a,b,c;
int main () {
	scanf("%d",&T);
	while (T--) {
		scanf("%d%d%d",&a,&b,&c);
		if (a<b) swap(a,b);
		if (a<c) swap(a,c);
		if (b<c) swap(b,c);
		int ans=0;
		if (a) ans++,a--;
		if (b) ans++,b--;
		if (c) ans++,c--;
		if (a&&b) ans++,a--,b--;
		if (a&&c) ans++,a--,c--;
		if (a&&b&&c) ans++,a--,b--,c--;
		printf ("%d\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1014;
int T;
int a,b,c;
int main () {
	scanf("%d",&T);
	while (T--) {
		scanf("%d%d%d",&a,&b,&c);
		if (a<b) swap(a,b);
		if (a<c) swap(a,c);
		if (b<c) swap(b,c);
		int ans=0;
		if (a) ans++,a--;
		if (b) ans++,b--;
		if (c) ans++,c--;
		if (a&&b) ans++,a--,b--;
		if (a&&c) ans++,a--,c--;
		if (b&&c) ans++,b--,c--;
		if (a&&b&&c) ans++,a--,b--,c--;
		printf ("%d\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1014;
int T;
int a,b,c;
int main () {
	scanf("%d",&T);
	while (T--) {
		scanf("%d%d%d",&a,&b,&c);
		//if (a<b) swap(a,b);
		//if (a<c) swap(a,c);
		//if (b<c) swap(b,c);
		int ans=0;
		if (a) ans++,a--;
		if (b) ans++,b--;
		if (c) ans++,c--;
		if (a&&b) ans++,a--,b--;
		if (a&&c) ans++,a--,c--;
		if (b&&c) ans++,b--,c--;
		if (a&&b&&c) ans++,a--,b--,c--;
		printf ("%d\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int a,b,c;

int main(){
	int cas;cin>>cas;
	while(cas--){
		scanf("%d%d%d",&a,&b,&c);
		int ans=0;
		if(a) ++ans,--a;
		if(b) ++ans,--b;
		if(c) ++ans,--c;
		if(a<b) swap(a,b);
		if(a<c) swap(a,c);
		if(b<c) swap(b,c);
		if(a&&b){
			--a;
			--b;
			++ans;
		}
		if(a&&c){
			--a;
			--c;
			++ans;
		}
		if(b&&c){
			--b;
			--c;
			++ans;
		}
		if(a&&b&&c) ++ans;
		printf("%d\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
#define REP(i,first,last) for(int i=first;i<=last;++i)
#define DOW(i,first,last) for(int i=first;i>=last;--i)
using namespace std;
int T;
int a,b,c;

int check()
{
	if(a>1&&b>1&&c>1)
	{
		a-=2;
		b-=2;
		c-=2;
		return 3;
	}
	if(a>1&&b&&c)
	{
		a-=2;
		b--;
		c--;
		return 2;
	}
	if(b>1&&a&&c)
	{
		b-=2;
		a--;
		c--;
		return 2;
	}
	if(c>1&&b&&a)
	{
		c-=2;
		b--;
		a--;
		return 2;
	}
	if(a&&b)
	{
		a--;
		b--;
		return 1;
	}
	if(a&&c)
	{
		a--;
		c--;
		return 1;
	}
	if(b&&c)
	{
		b--;
		c--;
		return 1;
	}
	return 0;
}
void work()
{
	scanf("%d%d%d",&a,&b,&c);
	int answer=0;
	if(a)
	{
		--a;
		answer++;
	}
	if(b)
	{
		--b;
		answer++;
	}
	if(c)
	{
		--c;
		answer++;
	}
	answer+=check();
	if(a&&b&&c)
	{
		answer++;
	}
	printf("%d\n",answer);
}
int main()
{
	scanf("%d",&T);
	REP(i,1,T)
	{
		work();
	}
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

int a,b,c;
int solve(){
	int res = 0;
	if(a<b) swap(a,b);	//a必须是是最大的
	if(a<c) swap(a,c);
	if(a>0) res++,a--;
	if(b>0) res++,b--;
	if(c>0) res++,c--;
	if(a>0&&b>0) res++,a--,b--;
	if(b>0&&c>0) res++,b--,c--;
	if(a>0&&c>0) res++,a--,c--;
	if(a>0&&b>0&&c>0) res++;
	return res;
}

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d %d %d",&a,&b,&c);

		printf("%d\n",solve());
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int a,b,c;

int main(){
	int cas;cin>>cas;
	while(cas--){
		scanf("%d%d%d",&a,&b,&c);
		int ans=0;
		if(a) ++ans,--a;
		if(b) ++ans,--b;
		if(c) ++ans,--c;
		if(a<=b&&a<=c&&b&&c){
			--b;--c;
			++ans;
		}
		if(b<=a&&b<=c&&a&&c){
			--a;--c;
			++ans;
		}
		if(c<=a&&c<=b&&a&&b){
			--a;--b;
			++ans;
		}
		if(a&&b&&c) ++ans;
		printf("%d\n",ans);
	}
	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#define int long long
using namespace std;
const int N=200005;
struct node
{
	int lma;
	int rma;
	int ma;
};
node tr[N<<1][3];
void up(int id,int k,int l,int r)
{
	int mid=(l+r)>>1;
	tr[k][id].lma=tr[k<<1][id].lma==(mid-l+1)?tr[k<<1][id].lma+tr[k<<1|1][id].lma:tr[k<<1][id].lma;
	tr[k][id].rma=tr[k<<1|1][id].rma==(r-mid)?tr[k<<1|1][id].rma+tr[k<<1][id].rma:tr[k<<1|1][id].rma;
	tr[k][id].ma=max(tr[k<<1][id].ma,tr[k<<1|1][id].ma);
	tr[k][id].ma=max(tr[k][id].ma,tr[k<<1][id].rma+tr[k<<1|1][id].lma);
}
void build(int id,int k,int l,int r)
{
	if(l==r) return (void) (tr[k][id].lma=tr[k][id].rma=tr[k][id].ma=1);
	int mid=(l+r)>>1;
	build(id,k<<1,l,mid);
	build(id,k<<1|1,mid+1,r);
	up(id,k,l,r);
}
void add(int id,int k,int l,int r,int pos)
{
	if(l==r) return(void)(tr[k][id].lma=tr[k][id].rma=tr[k][id].ma=0);
	int mid=(l+r)>>1;
	if(pos<=mid)
	add(id,k<<1,l,mid,pos);
	else
	add(id,k<<1|1,mid+1,r,pos);
	up(id,k,l,r);
}
int query(int id,int k,int l,int r,int ql,int qr)
{
	if(ql==l&&qr==r) return max(tr[k][id].ma,max(tr[k][id].lma,tr[k][id].rma));
	int mid=(l+r)>>1;
	if(qr<=mid)
	return query(id,k<<1,l,mid,ql,qr);
	else
	if(ql>mid)
	return query(id,k<<1|1,mid+1,r,ql,qr);
	else
	return max(query(id,k<<1,l,mid,ql,mid),query(id,k<<1|1,mid+1,r,mid+1,qr));
}
int w,h,q;
signed main()
{
	scanf("%lld%lld%lld",&w,&h,&q);
	build(1,1,1,w-1),build(2,1,1,h-1);
	for(int i=1;i<=q;i++)
	{
		char x;
		int y;
		cin>>x>>y;
		if(x=='H')add(2,1,1,h-1,y);
		else add(1,1,1,w-1,y);
		cout<<(query(1,1,1,w,1,w)+1)*(1+query(2,1,1,h,1,h))<<endl;
	}
}


#include<cstdio>
#include<iostream>
#include<set>
using namespace std;

#define LL long long
int w,h,m,t;
char c;
LL leftt,rightt;
set<LL> len,wid;
multiset<LL> leng,wide;
multiset<LL> ::iterator it;

int main(){
    scanf("%d%d%d",&w,&h,&m);
    leng.insert(w);wide.insert(h);
    len.insert(0);len.insert(w);
    wid.insert(0);wid.insert(h);
    for(int i = 1;i <= m;i++){
        cin >> c >> t;
        if(c == 'H'){
            wid.insert(t);
            it = wid.find(t);
            it--;leftt = *it;
            it++;it++;rightt = *it;
            it = wide.find(rightt-leftt);
            wide.erase(it);
            wide.insert(rightt-t);
            wide.insert(t-leftt);
        }
        else{
            len.insert(t);
            it = len.find(t);
            it--;leftt = *it;
            it++;it++;rightt = *it;
            it = leng.find(rightt-leftt);
            leng.erase(it);
            leng.insert(rightt-t);
            leng.insert(t-leftt);
        }
        it = wide.end();it--;
        leftt = *it;
        it = leng.end();it--;
        rightt = *it;
        printf("%lld\n",leftt*rightt);
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#define ri register int
#define int long long
using namespace std;
const int N=2e5+10;
int w,h,n;

struct node{
	int left,right;
	int maxn,lmax,rmax;
}disy[N<<2];

struct nod{
	int up,down;
	int maxn,upmax,dowx;
}disx[N<<2];

int read(){
	char ch=getchar();int re=0,op=1;
	while(ch<'0'||ch>'9'){
		if(ch=='-') op=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		re=(re<<3)+(re<<1)+ch-'0';
		ch=getchar();
	}
	return re*op;
}

void buildx(int id,int l,int r){
	disy[id].left=l;disy[id].right=r;
	if(l==r){
		disy[id].maxn=disy[id].lmax=disy[id].rmax=1;
		return ;
	}
	int mid=l+r>>1;
	buildx(id<<1,l,mid);buildx(id<<1|1,mid+1,r);
	disy[id].maxn=max(max(disy[id<<1].maxn,disy[id<<1|1].maxn),disy[id<<1].rmax+disy[id<<1|1].lmax);
	if(disy[id<<1].lmax==disy[id<<1].right-disy[id<<1].left+1) disy[id].lmax=disy[id<<1].lmax+disy[id<<1|1].lmax;
	else disy[id].lmax=disy[id<<1].lmax;
	if(disy[id<<1|1].rmax==disy[id<<1|1].right-disy[id<<1|1].left+1) disy[id].rmax=disy[id<<1].rmax+disy[id<<1|1].rmax;
	else disy[id].rmax=disy[id<<1|1].rmax;
}

void buildy(int id,int l,int r){
	disx[id].up=l;disx[id].down=r;
	if(l==r){
		disx[id].upmax=disx[id].dowx=disx[id].maxn=1;
		return ;
	}
	int mid=l+r>>1;
	buildy(id<<1,l,mid);buildy(id<<1|1,mid+1,r);
	disx[id].maxn=max(max(disx[id<<1].maxn,disx[id<<1|1].maxn),disx[id<<1].dowx+disx[id<<1|1].upmax);
	if(disx[id<<1].upmax==disx[id<<1].down-disx[id<<1].up+1) disx[id].upmax=disx[id<<1].upmax+disx[id<<1|1].upmax;
	else disx[id].upmax=disx[id<<1].upmax;
	if(disx[id<<1|1].dowx==disx[id<<1|1].down-disx[id<<1|1].up+1) disx[id].dowx=disx[id<<1].dowx+disx[id<<1|1].dowx;
	else disx[id].dowx=disx[id<<1|1].dowx;
}

void cut(int kind,int size,int l,int r,int id){
	if(l==r){
		if(kind==1) disx[id].upmax=disx[id].dowx=disx[id].maxn=0;
		else disy[id].maxn=disy[id].lmax=disy[id].rmax=0;
		return ;
	}
	int mid=l+r>>1;
	if(size<=mid) cut(kind,size,l,mid,id<<1);
	else cut(kind,size,mid+1,r,id<<1|1);
	if(kind==2){
		disy[id].maxn=max(max(disy[id<<1].maxn,disy[id<<1|1].maxn),disy[id<<1].rmax+disy[id<<1|1].lmax);
		if(disy[id<<1].lmax==disy[id<<1].right-disy[id<<1].left+1) disy[id].lmax=disy[id<<1].lmax+disy[id<<1|1].lmax;
		else disy[id].lmax=disy[id<<1].lmax;
		if(disy[id<<1|1].rmax==disy[id<<1|1].right-disy[id<<1|1].left+1) disy[id].rmax=disy[id<<1].rmax+disy[id<<1|1].rmax;
		else disy[id].rmax=disy[id<<1|1].rmax;
	}
	else if(kind==1){
		disx[id].maxn=max(max(disx[id<<1].maxn,disx[id<<1|1].maxn),disx[id<<1].dowx+disx[id<<1|1].upmax);
		if(disx[id<<1].upmax==disx[id<<1].down-disx[id<<1].up+1) disx[id].upmax=disx[id<<1].upmax+disx[id<<1|1].upmax;
		else disx[id].upmax=disx[id<<1].upmax;
		if(disx[id<<1|1].dowx==disx[id<<1|1].down-disx[id<<1|1].up+1) disx[id].dowx=disx[id<<1].dowx+disx[id<<1|1].dowx;
		else disx[id].dowx=disx[id<<1|1].dowx;
	}
}

signed main(){
	w=read(),h=read(),n=read();
	buildx(1,1,w-1);buildy(1,1,h-1);
	for(ri i=1;i<=n;i++){
		char ch=getchar();int size;
		while(ch<'A'||ch>'Z') ch=getchar();
		size=read();
		if(ch=='H') cut(1,size,1,h-1,1);
		else cut(2,size,1,w-1,1);
		printf("%d\n",(1+disx[1].maxn)*(1+disy[1].maxn));
	}
	return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

    #define in(a) a=read()
    #define out(a) write(a)
    #define outn(a) out(a),putchar('\n')

    #define I_int int
    inline I_int read() {
        I_int x = 0 , f = 1 ; char c = getchar() ;
        while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
        while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
        return x * f ;
    }
    char F[ 200 ] ;
    inline void write( I_int x ) {
        if( x == 0 ) { putchar( '0' ) ; return ; }
        I_int tmp = x > 0 ? x : -x ;
        if( x < 0 ) putchar( '-' ) ;
        int cnt = 0 ;
        while( tmp > 0 ) {
            F[ cnt ++ ] = tmp % 10 + '0' ;
            tmp /= 10 ;
        }
        while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
    }
    #undef I_int

}
using namespace io ;

using namespace std ;

#define N 1000100

int n = read(), m = read(), k = read();
struct tree {
	int l, r, mx, lm, rm, len;
} t[N<<2][2];

#define lc (rt << 1)
#define rc (rt << 1 | 1)
#define mid ((l + r) >> 1)

void pushup(int rt, int c) {
	t[rt][c].lm = t[lc][c].lm;
	if(t[lc][c].lm == t[lc][c].len) t[rt][c].lm += t[rc][c].lm;
	t[rt][c].rm = t[rc][c].rm;
	if(t[rc][c].rm == t[rc][c].len) t[rt][c].rm += t[lc][c].rm;
	t[rt][c].mx = max(t[rt][c].lm, t[rt][c].rm);
	t[rt][c].mx = max(t[rt][c].mx, t[lc][c].rm + t[rc][c].lm);
}

void build(int l, int r, int rt, int c) {
	t[rt][c].l = l; t[rt][c].r = r;
	t[rt][c].len = t[rt][c].mx = t[rt][c].lm = t[rt][c].rm = r - l + 1;
	if(l == r) return;
	build(l, mid, lc, c); build(mid + 1, r, rc, c);
	pushup(rt, c);
}

#define l (t[rt][c].l)
#define r (t[rt][c].r)
void upd(int pos, int rt, int c) {
	if(pos == l && pos == r) {
		t[rt][c].lm = t[rt][c].rm = t[rt][c].mx = 0;
		return;
	}
	if(pos <= mid) upd(pos, lc, c);
	else upd(pos, rc, c);
	pushup(rt, c);
}

#undef lc
#undef rc
#undef mid
#undef l
#undef r

int main() {
	build(1, n - 1, 1, 0); build(1, m - 1, 1, 1);
	for(int i = 1; i <= k; ++i) {
		char ch[20];
		scanf("%s", ch);
		int x = read();
		if(ch[0] == 'V') upd(x, 1, 0);
		else upd(x, 1, 1);
		printf("%lld\n", 1ll * (t[1][0].mx + 1) * (t[1][1].mx + 1));
	}
}


#include <bits/stdc++.h>

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace FastIO{struct Reader{char buf[1<<20],*s,*t;bool EOF_FLG;Reader():s(buf),t(buf),EOF_FLG(false) {};char gt() {return s==t&&((t=(s=buf)+fread(buf,1,1<<20,stdin))==s)?EOF:(*s++);}Reader& operator>>(char* str) {if(EOF_FLG)return *str=0,*this;while((*str=gt())!=' '&&*str!='\n'&&*str!=EOF)++str;if(*str==EOF)EOF_FLG=true;*str=0;return *this;}template<typename T>Reader&operator>>(T&x) {if(EOF_FLG)return *this;char c=0,d;while(c!=EOF&&(c<'0'||c>'9'))d=c,c=gt();if(c==EOF){EOF_FLG=true;return *this;}else x=0;while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=gt();if(d=='-')x=-x;return *this;}}in;struct Writer{char buf[1<<20],*s,*t;Writer():s(buf),t(buf+(1<<20)){}~Writer(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,1<<20,stdout),*s++=c):(*s++=c);}template<typename T>Writer&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[40],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}Writer&operator<<(const char*s) {while(*s)pt(*s++);return *this;}}out;}using namespace FastIO;
using namespace std ;

#define N 1000100

int n, m, k;
struct tree {
	int l, r;
	int mx, lm, rm, len;
} t[N<<2][2];

#define lc (rt << 1)
#define rc (rt << 1 | 1)

inline void pushup(int rt, int c) {
	if(t[lc][c].mx == t[lc][c].len) t[rt][c].lm = t[lc][c].mx + t[rc][c].lm;
	else t[rt][c].lm = t[lc][c].lm;
	if(t[rc][c].mx == t[rc][c].len) t[rt][c].rm = t[rc][c].mx + t[lc][c].rm;
	else t[rt][c].rm = t[rc][c].rm;
	t[rt][c].mx = max(t[lc][c].mx, t[rc][c].mx);
	t[rt][c].mx = max(t[rt][c].mx, t[lc][c].rm + t[rc][c].lm);
}

inline void build(int l, int r, int rt, int c) {
	t[rt][c].l = l; t[rt][c].r = r;
	t[rt][c].len = t[rt][c].mx = t[rt][c].lm = t[rt][c].rm = r - l + 1;
	int mid = (l + r) >> 1; if(l == r) return;
	build(l, mid, lc, c); build(mid + 1, r, rc, c);
}

#define l (t[rt][c].l)
#define r (t[rt][c].r)
inline void upd(int pos, int rt, int c) {
	if(pos == l && pos == r) {
		t[rt][c].lm = t[rt][c].rm = t[rt][c].mx = 0;
		return;
	}
	int mid = (l + r) >> 1;
	if(pos <= mid) upd(pos, lc, c);
	else upd(pos, rc, c);
	pushup(rt, c);
}

#undef lc
#undef rc
#undef l
#undef r

int main() {
#ifndef ONLINE_JUDGE
freopen("cake.in", "r", stdin);
freopen("cake.out", "w", stdout);
#endif
	in >> n >> m >> k;
	build(1, n - 1, 1, 0); build(1, m - 1, 1, 1);
	for(int i = 1; i <= k; ++i) {
		char ch[30]; int x;
		in >> ch >> x;
		if(ch[0] == 'H') upd(x, 1, 1);
		else upd(x, 1, 0);
		ll ans = 1ll * (t[1][0].mx + 1) * (t[1][1].mx + 1);
		outn(ans);
	}
}


#include<iostream>
#include<cstring>
#include<cstdio>
#define int long long
using namespace std;
const int N=200005;
struct node
{
	int lma;
	int rma;
	int ma;
};
node tr[N<<2][3];
void up(int id,int k,int l,int r)
{
	int mid=(l+r)>>1;
	tr[k][id].lma=tr[k<<1][id].lma==(mid-l+1)?tr[k<<1][id].lma+tr[k<<1|1][id].lma:tr[k<<1][id].lma;
	tr[k][id].rma=tr[k<<1|1][id].rma==(r-mid)?tr[k<<1|1][id].rma+tr[k<<1][id].rma:tr[k<<1|1][id].rma;
	tr[k][id].ma=max(tr[k<<1][id].ma,tr[k<<1|1][id].ma);
	tr[k][id].ma=max(tr[k][id].ma,tr[k<<1][id].rma+tr[k<<1|1][id].lma);
}
void build(int id,int k,int l,int r)
{
	if(l==r) return (void) (tr[k][id].lma=tr[k][id].rma=tr[k][id].ma=1);
	int mid=(l+r)>>1;
	build(id,k<<1,l,mid);
	build(id,k<<1|1,mid+1,r);
	up(id,k,l,r);
}
void add(int id,int k,int l,int r,int pos)
{
	if(l==r) return(void)(tr[k][id].lma=tr[k][id].rma=tr[k][id].ma=0);
	int mid=(l+r)>>1;
	if(pos<=mid)
	add(id,k<<1,l,mid,pos);
	else
	add(id,k<<1|1,mid+1,r,pos);
	up(id,k,l,r);
}
int query(int id,int k,int l,int r,int ql,int qr)
{
	if(ql==l&&qr==r) return max(tr[k][id].ma,max(tr[k][id].lma,tr[k][id].rma));
	int mid=(l+r)>>1;
	if(qr<=mid)
	return query(id,k<<1,l,mid,ql,qr);
	else
	if(ql>mid)
	return query(id,k<<1|1,mid+1,r,ql,qr);
	else
	return max(query(id,k<<1,l,mid,ql,mid),query(id,k<<1|1,mid+1,r,mid+1,qr));
}
int w,h,q;
signed main()
{
	scanf("%lld%lld%lld",&w,&h,&q);
	build(1,1,1,w-1),build(2,1,1,h-1);
	for(int i=1;i<=q;i++)
	{
		char x;
		int y;
		cin>>x>>y;
		if(x=='H')add(2,1,1,h-1,y);
		else add(1,1,1,w-1,y);
		cout<<(query(1,1,1,w,1,w)+1)*(1+query(2,1,1,h,1,h))<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
set<int>H,V;
int mh[maxn],mv[maxn];
void cut(set<int>&s,int *a,int val){
    s.insert(val);
    set<int>::iterator l,r;
    l=r=s.find(val);
    l--;
	r++;
    a[*r-*l]--;
    a[*r-val]++;
    a[val-*l]++;
}
int main(){
	int n,h,v,x,maxh,maxv;
    scanf("%d %d %d",&v,&h,&n);
    mh[h]=1;
	mv[v]=1;
    H.insert(h);
	V.insert(v);
    H.insert(0);
	V.insert(0);
    maxh=h;
	maxv=v;
    char ch;
    while(n--){
    	cin >> ch;
        scanf("%d",&x);
        ch=='H'?cut(H,mh,x):cut(V,mv,x);
        while(!mh[maxh]) maxh--;
        while(!mv[maxv]) maxv--;
        long long ans=maxh*maxv;
        printf("%lld\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define MAXN 200001
using namespace std;
ll sum_y[MAXN<<2][3],sum_m[MAXN<<2][3],sum_z[MAXN<<2][3];
ll w,h,n;
bool ifzero[MAXN<<2][3];
int read()
{
	int 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<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
void update(int v,int whi)
{
	if(ifzero[v<<1][whi]) sum_z[v][whi]=sum_z[v<<1][whi]+sum_z[v<<1|1][whi];
	else sum_z[v][whi]=sum_z[v<<1][whi];
	if(ifzero[v<<1|1][whi]) sum_y[v][whi]=sum_y[v<<1|1][whi]+sum_y[v<<1][whi];
	else sum_y[v][whi]=sum_y[v<<1|1][whi];
	sum_m[v][whi]=max(sum_y[v<<1][whi]+sum_z[v<<1|1][whi],max(sum_m[v<<1][whi],sum_m[v<<1|1][whi]));
	if(ifzero[v<<1][whi]&&ifzero[v<<1|1][whi])
	ifzero[v][whi]=true;
	else ifzero[v][whi]=false;
}
void build(int l,int r,int v,int whi)
{
	if(l==r)
	{
		sum_y[v][whi]=1;
		sum_z[v][whi]=1;
		sum_m[v][whi]=1;
		ifzero[v][whi]=true;
		return;
	}
	int m=(l+r)/2;
	build(l,m,v<<1,whi);
	build(m+1,r,v<<1|1,whi);
	update(v,whi);
}
void fix(int l,int r,int v,int source,int whi)
{
	if(l==r)
	{
		sum_y[v][whi]=0;
		sum_z[v][whi]=0;
		sum_m[v][whi]=0;
		ifzero[v][whi]=false;
		return;
	}
	int m=(l+r)/2;
	if(source<=m)
	fix(l,m,v<<1,source,whi);
	else
	fix(m+1,r,v<<1|1,source,whi);
	update(v,whi);
}
int main()
{
	char ch; int x;
	w=read();
	h=read();
	n=read();
	build(1,w-1,1,1);
	build(1,h-1,1,2);
	for(int i=1;i<=n;i++)
	{
		ch=getchar();
		x=read();
		if(ch=='H')
		fix(1,h-1,1,x,2);
		if(ch=='V')
		fix(1,w-1,1,x,1);
		cout<<(sum_m[1][1]+1)*(sum_m[1][2]+1)<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

multiset<int> h;
multiset<int> v;
map<int,int> h_l;
map<int,int> v_l;

void cut(int x, map<int,int> &seg, multiset<int> &bst) {
	//find the seg it cuts
	map<int , int>::iterator it = seg.lower_bound(x);
	it--;
	//create two new segs
	pair<int,int> s1 = make_pair(it->first,x);
	pair<int,int> s2 = make_pair(x,it->second);

	//delete the old seg
	seg.erase(it);
	bst.erase(bst.find(it->second - it->first));

	//insert those new segs
	seg.insert(s1);
	seg.insert(s2);
	//length
	bst.insert(s1.second - s1.first);
	bst.insert(s2.second - s2.first);
}

int main() {
	int w,hs,n;
	scanf("%d %d %d",&w,&hs,&n);
	h_l[0] = hs;
	v_l[0] = w;
	h.insert(hs);
	v.insert(w);
	for (int i = 1; i <= n; i++) {
		char c[2];
		int dis;
		scanf("%s %d",&c,&dis);
		if (c[0] == 'H') {
			cut(dis, h_l, h);
		}else{
			cut(dis, v_l, v);
		}
		int x = *--h.end();
		int y = *--v.end();
		printf("%d\n",x*y);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<string>
#include<vector>
#include<queue>
#define kl (k*2)
#define mid ((l+r)/2)
#define sum （r-l+1)
using namespace std;
int n,m,x,y,q,p,h,w;
char c;
struct tree{
    int lazy,maxx,lmaxx,rmaxx,len;
    bool check;
}t[500000][4];
void ud(int k,int l,int r,int f)
{
    if(t[kl][f].maxx==t[kl][f].len&&!t[k][f].check)
    {
        t[k][f].lmaxx=t[kl][f].len+t[kl+1][f].lmaxx;
    }
    else
    {
        t[k][f].lmaxx=t[kl][f].lmaxx;
    }
    if(t[kl+1][f].len==t[kl+1][f].maxx&&!t[k][f].check)
    {
        t[k][f].rmaxx=t[kl+1][f].len+t[kl][f].rmaxx;
    }
    else
    {
        t[k][f].rmaxx=t[kl+1][f].rmaxx;
    }
    t[k][f].maxx=max(t[kl][f].maxx,t[kl+1][f].maxx);
    if(!t[k][f].check)
    t[k][f].maxx=max(t[kl][f].rmaxx+t[kl+1][f].lmaxx,t[k][f].maxx);
}
void bu(int k,int l,int r,int f)
{
    t[k][f].len=t[k][f].lmaxx=t[k][f].maxx=t[k][f].rmaxx=r-l+1;
//	cout<<k<<' '<<l<<' '<<r<<endl;
    if(l==r)
    return;
    bu(kl,l,mid,f);
    bu(kl+1,mid+1,r,f);
}
void ch(int k,int l,int r,int f)
{
//	pd(k,l,r);
	if(mid==x)
	{
		t[k][f].maxx=max(t[kl][f].maxx,t[kl+1][f].maxx);
		t[k][f].lmaxx=t[kl][f].lmaxx;
		t[k][f].rmaxx=t[kl+1][f].rmaxx;
		t[k][f].check=true;
		return;
    }
    if(t[k][f].len==3)
	{
		t[k][f].maxx=t[kl+1][f].maxx;
		t[k][f].lmaxx=1;
		t[k][f].rmaxx=t[kl+1][f].rmaxx;
		t[k][f].check=true;
		return;
	}
    if(x<mid)
    ch(kl,l,mid,f);
	else if(x>mid)
    ch(kl+1,mid+1,r,f);
    ud(k,l,r,f);
}
int main()
{
//	freopen("qwq.out","w",stdout);
    cin>>w>>h>>n;

	bu(1,1,w,1);
	bu(1,1,h,2);
    for(int i=1;i<=n;i++)
    {
		scanf("%c",&c);
		scanf("%c",&c);
		if(c=='H')
        {
        	cin>>x;
        	x=h-x;
            ch(1,1,h,2);
        }
        else
        {
        	cin>>x;
			ch(1,1,w,1);
        }
        cout<<t[1][1].maxx*t[1][2].maxx<<endl;
    }
    return 0;
}
/*
4 3 4
H 2
V 2
V 3
V 1
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
set<int>la,lb;
multiset<int>a,b;
multiset<int>::iterator it;
main(){
	int x,y,n,t,l,r;
	char c;
	cin>>x>>y>>n;
    a.insert(x),b.insert(y),la.insert(0),la.insert(x),lb.insert(0),lb.insert(y);
    for(int i=1;i<=n;i++){
		cin>>c>>t;
        if(c=='H'){
            lb.insert(t),it=lb.find(t),it--,l=*it,it++,it++,r=*it,it=b.find(r-l),b.erase(it),b.insert(r-t),b.insert(t-l);
        }
        else{
			la.insert(t),it=la.find(t),it--,l=*it,it++,it++,r=*it,it=a.find(r-l),a.erase(it),a.insert(r-t),a.insert(t-l);
        }
        it=a.end(),it--,l=*it,it=b.end();it--,r=*it;
		cout<<l*r<<"\n";
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
int w,h,n,x,emp1[1000010],emp2[1000010];
long long sum1[1000010],ls1[1000010],rs1[1000010];
long long sum2[1000010],ls2[1000010],rs2[1000010];
void updata1(int now)
{
	sum1[now]=max(sum1[now*2],sum1[now*2+1]);
	sum1[now]=max(sum1[now],rs1[now*2]+ls1[now*2+1]);
	if (emp1[now*2]&&emp1[now*2+1])
	{
		emp1[now]=1;
		ls1[now]=rs1[now]=sum1[now];
	}
	else if (emp1[now*2])
	{
		emp1[now]=0;
		ls1[now]=sum1[now*2]+ls1[now*2+1];
		rs1[now]=rs1[now*2+1];
	}
	else if (emp1[now*2+1])
	{
		emp1[now]=0;
		rs1[now]=sum1[now*2+1]+rs1[now*2];
		ls1[now]=ls1[now*2];
	}
	else
	{
		emp1[now]=0;
		ls1[now]=ls1[now*2];
		rs1[now]=rs1[now*2+1];
	}
}
void updata2(int now)
{
	sum2[now]=max(sum2[now*2],sum2[now*2+1]);
	sum2[now]=max(sum2[now],rs2[now*2]+ls2[now*2+1]);
	if (emp2[now*2]&&emp2[now*2+1])
	{
		emp2[now]=1;
		ls2[now]=rs2[now]=sum2[now];
	}
	else if (emp2[now*2])
	{
		emp2[now]=0;
		ls2[now]=sum2[now*2]+ls2[now*2+1];
		rs2[now]=rs2[now*2+1];
	}
	else if (emp2[now*2+1])
	{
		emp2[now]=0;
		rs2[now]=sum2[now*2+1]+rs2[now*2];
		ls2[now]=ls2[now*2];
	}
	else
	{
		emp2[now]=0;
		ls2[now]=ls2[now*2];
		rs2[now]=rs2[now*2+1];
	}
}
void build1(int now,int l,int r)
{
	if (l==r)
	{
		sum1[now]=ls1[now]=rs1[now]=1;
		emp1[now]=1;
		return;
	}
	int mid=(l+r)/2;
	build1(now*2,l,mid);
	build1(now*2+1,mid+1,r);
	updata1(now);
}
void build2(int now,int l,int r)
{
	if (l==r)
	{
		sum2[now]=ls2[now]=rs2[now]=1;
		emp2[now]=1;
		return;
	}
	int mid=(l+r)/2;
	build2(now*2,l,mid);
	build2(now*2+1,mid+1,r);
	updata2(now);
}
void change1(int now,int l,int r)
{
	if (l==r)
	{
		sum1[now]=ls1[now]=rs1[now]=0;
		emp1[now]=0;
		return;
	}
	int mid=(l+r)/2;
	if (mid>=x)
	change1(now*2,l,mid);
	else
	change1(now*2+1,mid+1,r);
	updata1(now);
	return;
}
void change2(int now,int l,int r)
{
	if (l==r)
	{
		sum2[now]=ls2[now]=rs2[now]=0;
		emp2[now]=0;
		return;
	}
	int mid=(l+r)/2;
	if (mid>=x)
	change2(now*2,l,mid);
	else
	change2(now*2+1,mid+1,r);
	updata2(now);
	return;
}
int main()
{
	scanf("%d%d%d",&w,&h,&n);
	build1(1,1,w-1);
	build2(1,1,h-1);
/*	int i=1;
	while(sum1[i])
	{
		cout<<sum1[i]<<endl;
		i++;
	}*/
	for (int i=1;i<=n;i++)
	{
		char ch;
		cin>>ch>>x;
		if (ch=='V')
		{
			change1(1,1,w-1);
			cout<<(sum1[1]+1)*(sum2[1]+1)<<endl;
		}
		else
		{
			change2(1,1,h-1);
			cout<<(sum1[1]+1)*(sum2[1]+1)<<endl;
		}
	}
	return 0;
}


#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
set<int>h,w;
multiset<int>h1,w1;
int n,m,T,a,b;
char s[5];
set<int>::iterator it,pre,nxt;
multiset<int>::iterator tmp;
inline void init(){
    w.insert(m);w.insert(0);h.insert(n);h.insert(0);w1.insert(m);h1.insert(n);
}
int main(){
    scanf("%d%d%d",&n,&m,&T);
    init();
    while(T--){
        int x;
        scanf("%s%d",s,&x);
        if(s[0]=='V'){
            h.insert(x);
            it=nxt=pre=h.find(x);
            nxt++;pre--;
            tmp=h1.find(*nxt-*pre);
            h1.erase(tmp);
            h1.insert(x-*pre);
            h1.insert(*nxt-x);
        }else{
            w.insert(x);
            it=nxt=pre=w.find(x);
            nxt++;pre--;
            tmp=w1.find(*nxt-*pre);
            w1.erase(tmp);
            w1.insert(x-*pre);
            w1.insert(*nxt-x);
        }
        multiset<int>::iterator t1,t2;
        t1=w1.end();t1--;
        t2=h1.end();t2--;
        long long egg=(long long)(*t1)*(*t2);
        printf("%lld\n",egg);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN 401000
#define int long long
int sum_z[MAXN][5];
int sum_y[MAXN][5];
int sum_m[MAXN][5];
bool ifallzero[MAXN][5];
void update(int now,int horz)
{
	if(ifallzero[now<<1][horz]==1)//左儿子全零
		sum_z[now][horz]=sum_z[now<<1][horz]+sum_z[now<<1|1][horz];//当前左边等于左边的全部+右边的左边
	else
		sum_z[now][horz]=sum_z[now<<1][horz];//否则当前左边等于左儿子左边

	if(ifallzero[now<<1|1][horz]==1)//右儿子全零
		sum_y[now][horz]=sum_y[now<<1|1][horz]+sum_y[now<<1][horz];//同上
	else
		sum_y[now][horz]=sum_y[now<<1|1][horz];//同上

	sum_m[now][horz]=max((sum_y[now<<1][horz]+sum_z[now<<1|1][horz]),max(sum_m[now<<1][horz],sum_m[now<<1|1][horz]));//中间等于左边的右边+右边的左边与左右两边最大值的最大值

	if(ifallzero[now<<1][horz]==1&&ifallzero[now<<1|1][horz]==1)
	ifallzero[now][horz]=1;//左右全零和全零
}
void build(int now,int l,int r,int horz)
{
	if(l==r)
	{
		sum_z[now][horz]=1;
		sum_y[now][horz]=1;
		sum_m[now][horz]=1;
		ifallzero[now][horz]=1;
		return ;
	}
	int mid=(l+r)>>1;
	build(now<<1,l,mid,horz);
	build(now<<1|1,mid+1,r,horz);
	update(now,horz);
}
void change(int now,int l,int r,int lgo,int rgo,int horz)
{
	if(l>=lgo&&r<=rgo)
	{
		ifallzero[now][horz]=0;
		sum_z[now][horz]=0;
		sum_y[now][horz]=0;
		sum_m[now][horz]=0;
		return ;
	}
	int mid=(l+r)>>1;
	if(lgo<=mid)
	change(now<<1,l,mid,lgo,rgo,horz);
	if(rgo>mid)
	change(now<<1|1,mid+1,r,lgo,rgo,horz);
	update(now,horz);
}
signed main()
{
	int w,h,n,x;
	char o;
	cin>>w>>h>>n;
	build(1,1,w-1,1);//横
	build(1,1,h-1,2);//竖
	for(int i=1;i<=n;i++)
	{
		cin>>o;
		if(o=='H')
		{
			cin>>x;
			change(1,1,w-1,x,x,1);
		}
		if(o=='V')
		{
			cin>>x;
			change(1,1,h-1,x,x,1);
		}
		cout<<(sum_m[1][1]+1)*(sum_m[1][2]+1)<<endl;
	}
}


#include <iostream>
#include <fstream>
#include <cmath>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <bitset>
#include <set>
//#include <cstdint>
#include <algorithm>

using namespace std;
/*
enum ctype{
    none  =0x00,
    x_axis=0x01,
    y_axis=0x02
};

class sqr{
private:
    unsigned int w,h;
    unsigned char cut=none,wh=0;
public:
    sqr *l=NULL,*r=NULL;
public:
    sqr(){}
    sqr(unsigned int aw,unsigned int ah):w(aw),h(ah){}

    inline unsigned int maxArea(){
        return cut?max(l->maxArea(),r->maxArea()):w*h;
    }
    void cut_h(unsigned int _wh){
        if(_wh==0||_wh==h)return;
        switch(cut){
            case none:
                cut=x_axis;
                wh=_wh;
                l=new sqr(w,wh);
                r=new sqr(w,h-wh);
                break;
            case x_axis:
                if(wh==_wh)break;
                else ((_wh>wh)?(r):(l))->cut_h((_wh>wh)?(_wh-wh):_wh);
                break;
            case y_axis:
                l->cut_h(_wh);
                r->cut_h(_wh);
                break;
            default:
                //cnm
                break;
        }
    }
    void cut_v(unsigned int _wh){
        if(_wh==0||_wh==w)return;
        switch(cut){
            case none:
                cut=y_axis;
                wh=_wh;
                l=new sqr(wh,h);
                r=new sqr(w-wh,h);
                break;
            case x_axis:
                l->cut_v(_wh);
                r->cut_v(_wh);
                break;
            case y_axis:
                if(wh==_wh)break;
                else ((_wh>wh)?(r):(l))->cut_v((_wh>wh)?(_wh-wh):_wh);
                break;
            default:
                //cnm
                break;
        }
    }
};
*/
int main(int argc , char **argv){

    unsigned int n,w,h; cin>>w>>h>>n;

    multiset<unsigned int> x,y;

    x.insert(w);    y.insert(h);
    x.insert(0);    y.insert(0);

    char opt;   unsigned int p;

    unsigned int lx,ly;

    multiset<unsigned int>::iterator it;

    while(n--){

        cin>>opt>>p;

        if(opt=='H')y.insert(p);
        else        x.insert(p);

        it=x.begin();   it++;
        unsigned int last=*(x.begin()),xmax=0;
        for(;it!=x.end();last=*(it++))xmax=max(xmax,(*it)-last);

        it=y.begin();   it++;
        last=*(y.begin());
        unsigned int ymax=0;
        for(;it!=y.end();last=*(it++))ymax=max(ymax,(*it)-last);

        cout<<xmax*ymax<<endl;

    }

    return 0;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int w=4,h=3,n=4;
	multiset<int> x;
	multiset<int> y;
	set<int> sx;
	set<int> sy;
	cin>>w>>h>>n;
	sx.insert(0);
    sx.insert(h);
    sy.insert(w);
    sy.insert(0);
    x.insert(h);
    y.insert(w);
    while(n--)
    {
    	char c;
        int p;
       	cin>>c;
        scanf("%d",&p);
        //c='H',p=2;
    	if(c=='V')
    	{
    		sy.insert(p);
    		set<int>::iterator it=sy.lower_bound(p);
    		set<int>::iterator iit=sy.upper_bound(p);
    		it--;
    		//cout<<*iit<<" "<<*it<<" "<<endl;
            y.erase(y.find(*iit-*it));
            y.insert(p-*it);
            y.insert(*iit-p);
		}
		if(c=='H')
    	{
    		sx.insert(c);
    		set<int>::iterator it=sx.lower_bound(p);
    		set<int>::iterator iit=sx.upper_bound(p);
    		it--;
    		//cout<<*iit<<" "<<*it<<" "<<endl;
            x.erase(x.find(*iit-*it));
            x.insert(p-*it);
            x.insert(*iit-p);
		}
		int a=*(--x.end());
		int b=*(--y.end());
		//cout<<a<<" "<<b<<endl;
        cout<<a*b<<endl;
	}
	return 0;
}


#include<cstdio>
#include<cstring>

template<typename T>
inline bool updmax(T &x,T y){
    if(y>x)return x=y,true;
    return false;
}
template<typename T>
inline bool read(T &x){
    x=0;char c;T f=1;
    do{c=getchar();if(c=='-')f=-1;else if(c==EOF)return false;}
    while(c>'9'||c<'0');

    do{x=x*10+c-'0';c=getchar();}while(c>='0'&&c<='9');
    return x*=f,true;
}
inline void ReadChar(char &c){
    do{c=getchar();}while(c!='H'&&c!='V'&&c!=EOF);
}
const int N=200010;
int w,h,n;
int numw[N],numh[N];
struct SgmentTree{
    #define lson (p<<1)
    #define rson (p<<1|1)
    #define l(x) (S[x].l)
    #define r(x) (S[x].r)
    #define L(x) (S[x].L)
    #define len(x) (S[x].len)
    struct Node{
        int len,L;
        int l,r;
    }S[N<<2];
    int idx;
    inline void update(int p){
        len(p)=0;
        if(updmax(len(p),len(lson))){
            L(p)=L(lson);
        }
        if(updmax(len(p),len(rson))){
            L(p)=L(rson);
        }
    }
    void build(int p,int l,int r){
        l(p)=l;
        r(p)=r;
        if(l==r){
            if(idx){
                numh[l]=p;
            }
            else{
                numw[l]=p;
            }
            return;
        }
        int mid=(l+r)>>1;
        build(lson,l,mid);
        build(rson,mid+1,r);
    }
    void change(int p,int to,int len,int L){
        if(l(p)==r(p)){
            len(p)=len;
            L(p)=L;
            return;
        }
        int mid=(l(p)+r(p))>>1;
        if(to<=mid){
            change(lson,to,len,L);
        }
        else{
            change(rson,to,len,L);
        }
        update(p);
    }
}STW,STH;
struct FenwickTree{
    int v[N],maxv;
    inline void add(int x,int y){
        for(;x<=maxv;x+=x&-x){
            v[x]+=y;
        }
    }
    inline int ask(int x){
        int res=0;
        for(;x>0;x-=x&-x){
            res+=v[x];
        }
        return res;
    }
}FTW,FTH;

int main(){
    // freopen("testin.txt","r",stdin);
    // freopen("testout.txt","w",stdout);
    read(w);
    read(h);
    read(n);
    STW.idx=0;
    STH.idx=1;
    FTW.maxv=w;
    FTH.maxv=h;
    FTW.add(1,1);FTW.add(w+1,-1);
    FTH.add(1,1);FTH.add(h+1,-1);

    STW.build(1,1,n);
    STW.change(1,1,w,1);

    STH.build(1,1,n);
    STH.change(1,1,h,1);
    char c;
    int pos,toth=1,totw=1,nowid,preL,prelen,nowlen;
    for(register int i=1;i<=n;++i){
        ReadChar(c);
        read(pos);
        if(c=='H'){
            nowid=FTH.ask(pos);
            preL=STH.S[numh[nowid]].L;
            prelen=STH.S[numh[nowid]].len;
            nowlen=pos-preL+1;
            ++toth;
            FTH.add(pos+1,(toth-nowid));
            FTH.add(preL+prelen,nowid-toth);
            STH.change(1,nowid,nowlen,preL);
            STH.change(1,toth,prelen-nowlen,pos+1);
        }
        else{
            nowid=FTW.ask(pos);
            preL=STW.S[numw[nowid]].L;
            prelen=STW.S[numw[nowid]].len;
            nowlen=pos-preL+1;
            ++totw;
            FTW.add(pos+1,(totw-nowid));
            FTW.add(preL+prelen,nowid-totw);
            STW.change(1,nowid,nowlen,preL);
            STW.change(1,totw,prelen-nowlen,pos+1);
        }
        // printf("maxH:%d maxW:%d\n",STH.S[1].len,STW.S[1].len);
        printf("%lld\n",(long long)STH.S[1].len*STW.S[1].len);
    }

    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define ri register int
#define For(i,a,b) for(ri i=(a);i<=(b);++i)
#define DFor(i,a,b) for(ri i=(a);i>=(b);--i)
#define MAXN 200005
template<class T>inline T Max(register T a,register T b){return a>b?a:b;}
template<class T>inline T Min(register T a,register T b){return a<b?a:b;}
int w,h,n;
int p[MAXN<<2][2],mx[MAXN<<2][2],L[MAXN<<2][2],R[MAXN<<2][2];
template<class T>inline void read(T&x){
  char ch=getchar();x=0;
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
}
inline void push(int rt,int ln,int rn,int d){
	p[rt][d]=p[ln][d]&p[rn][d];
	mx[rt][d]=Max(R[ln][d]+L[rn][d],Max(mx[ln][d],mx[rn][d]));
	L[rt][d]=L[ln][d]+(p[ln][d]?L[rn][d]:0);
	R[rt][d]=R[rn][d]+(p[rn][d]?R[ln][d]:0);
}
void build(int l,int r,int rt,int d){
	if(l==r){
		L[rt][d]=R[rt][d]=mx[rt][d]=1;
		p[rt][d]=1;
		return;
	}
	int mid=l+r>>1,ln=rt<<1,rn=ln|1;
	build(l,mid,ln,d),build(mid+1,r,rn,d);
	push(rt,ln,rn,d);
}
void updata(int x,int l,int r,int rt,int d){
	if(l==r){
		L[rt][d]=R[rt][d]=mx[rt][d]=0;p[rt][d]=0;
		return;
	}
	int mid=l+r>>1,ln=rt<<1,rn=ln|1;
	if(x<=mid)updata(x,l,mid,ln,d);
	else updata(x,mid+1,r,rn,d);
	push(rt,ln,rn,d);
}
int main(){
//freopen(".in","r",stdin);freopen(".out","w",stdout);
	read(w),read(h),read(n);w<<=1;h<<=1;--w,--h;
	build(1,w,1,0),build(1,h,1,1);
	//printf("%d %d\n",mx[1][0]+1>>1,mx[1][1]+1>>1);
	For(i,1,n){
		char ch=getchar();while(ch!='H'&&ch=='V')ch=getchar();
		if(ch=='H'){
			int k=1,x;read(x);x<<=1;
			updata(x,1,h,1,k);
		}
		else{
			int k=0,x;read(x);x<<=1;
			updata(x,1,w,1,k);
		}
		printf("%lld\n",1ll*(mx[1][0]+1>>1)*(mx[1][1]+1>>1));
	}
 return 0;
}


#include <iostream>
#include <fstream>
#include <cmath>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <bitset>
#include <set>
//#include <cstdint>
#include <algorithm>

using namespace std;

enum ctype{
    none  =0x00,
    x_axis=0x01,
    y_axis=0x02
};

class sqr{
private:
    unsigned int w,h;
    unsigned char cut=none,wh=0;
    unsigned int maxarea;
    bool c=true;
    sqr *l=NULL,*r=NULL;
public:
    sqr(){}
    sqr(unsigned int aw,unsigned int ah):w(aw),h(ah){}
    /*~sqr(){
        if(l!=NULL){
            l->~sqr();
            delete l;
        }
        if(r!=NULL){
            r->~sqr();
            delete r;
        }
    }*/
    inline unsigned int maxArea(){
        if(c){
            if(cut)maxarea=max(l->maxArea(),r->maxArea());
            else   maxarea=w*h;
            c=false;
        }
        return maxarea;
    }
    void cut_h(unsigned int _wh){
        if(_wh==0||_wh==h)return;
        switch(cut){
            case none:
                c=true;
                cut=x_axis;
                wh=_wh;
                l=new sqr(w,wh);
                r=new sqr(w,h-wh);
                break;
            case x_axis:
                if(wh==_wh)break;
                else ((_wh>wh)?(r):(l))->cut_h((_wh>wh)?(_wh-wh):_wh),c=true;
                break;
            case y_axis:
                c=true;
                l->cut_h(_wh);
                r->cut_h(_wh);
                break;
            default:
                //cnm
                break;
        }
    }
    void cut_v(unsigned int _wh){
        if(_wh==0||_wh==w)return;
        switch(cut){
            case none:
                c=true;
                cut=y_axis;
                wh=_wh;
                l=new sqr(wh,h);
                r=new sqr(w-wh,h);
                break;
            case x_axis:
                c=true;
                l->cut_v(_wh);
                r->cut_v(_wh);
                break;
            case y_axis:
                if(wh==_wh)break;
                else ((_wh>wh)?(r):(l))->cut_v((_wh>wh)?(_wh-wh):_wh),c=true;
                break;
            default:
                //cnm
                break;
        }
    }
};

int main(int argc , char **argv){

    unsigned int n,w,h; cin>>w>>h>>n;

    sqr a(w,h);

    char opt;   unsigned int p;

    while(n--){
        cin>>opt>>p;
        if(opt=='H')a.cut_h(p);
        else        a.cut_v(p);
        cout<<a.maxArea()<<endl;
    }

    return 0;

}


#include<bits/stdc++.h>
#define clean(a,i) memset(a,i,sizseof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl int
#define re register
#define ri re int
#define rl re ll
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;!isdigit(k);k=getchar()) if(k=='-') f=-1;
	for(;isdigit(k);k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
struct Line{
	int l,r,val;
}H[200005],L[200005];
struct Res{
	char opt;
	int x;
}s[200005];
int w,h,n,bx,by;
ll ans[200005];
bool fx[200005],fy[200005];
int main(){
	read(w),read(h),read(n);
	for(ri i=1;i<=n;i++){
		cin>>s[i].opt;read(s[i].x);
		if(s[i].opt=='H') fx[s[i].x]=1;
		else fy[s[i].x]=1;
	}
	fx[h]=1,fy[w]=1;
	for(ri i=0,now=0;i<=h;i++)
		if(fx[i])
			H[i].l=now,H[now].r=i,H[i].val=i-now,now=i,bx=max(bx,H[i].val);
	for(ri i=0,now=0;i<=w;i++)
		if(fy[i])
			L[i].l=now,L[now].r=i,L[i].val=i-now,now=i,by=max(by,L[i].val);
	H[h].r=h,L[w].r=w,ans[n]=1LL*bx*by;
	for(ri i=n;i>=2;i--){
		if(s[i].opt=='H'){
			H[H[s[i].x].r].val+=H[s[i].x].val;
			H[H[s[i].x].r].l=H[s[i].x].l;
			H[H[s[i].x].l].r=H[s[i].x].r;
			bx=max(bx,H[H[s[i].x].r].val);
		}
		else{
			L[L[s[i].x].r].val+=L[s[i].x].val;
			L[L[s[i].x].r].l=L[s[i].x].l;
			L[L[s[i].x].l].r=L[s[i].x].r;
			by=max(by,L[L[s[i].x].r].val);
		}
		ans[i-1]=1LL*bx*by;
	}
	for(ri i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
inline long long read()
{
   long long s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
const long long maxn=200050;
long long n,m,q;
struct node
{
    long long l,r,res,ls,rs;
}t1[maxn*8],t2[maxn*8];
void pushup1(long long x)
{
    t1[x].ls=t1[x<<1].ls;
    if(t1[x<<1].ls==t1[x<<1].r-t1[x<<1].l+1)
        t1[x].ls+=t1[x<<1|1].ls;
    t1[x].rs=t1[x<<1|1].rs;
    if(t1[x<<1|1].rs==t1[x<<1|1].r-t1[x<<1|1].l+1)
        t1[x].rs+=t1[x<<1].rs;
    t1[x].res=max(t1[x<<1].res,t1[x<<1|1].res);
    t1[x].res=max(t1[x].res,max(t1[x].ls,t1[x].rs));
    t1[x].res=max(t1[x].res,t1[x<<1].rs+t1[x<<1|1].ls);
}
void pushup2(long long x)
{
    t2[x].ls=t2[x<<1].ls;
    if(t2[x<<1].ls==t2[x<<1].r-t2[x<<1].l+1)
        t2[x].ls+=t2[x<<1|1].ls;
    t2[x].rs=t2[x<<1|1].rs;
    if(t2[x<<1|1].rs==t2[x<<1|1].r-t2[x<<1|1].l+1)
        t2[x].rs+=t2[x<<1].rs;
    t2[x].res=max(t2[x<<1].res,t2[x<<1|1].res);
    t2[x].res=max(t2[x].res,max(t2[x].ls,t2[x].rs));
    t2[x].res=max(t2[x].res,t2[x<<1].rs+t2[x<<1|1].ls);
}
void build1(long long x,long long l,long long r)
{
    t1[x].l=l;
    t1[x].r=r;
    if(l==r)
    {
        t1[x].res=t1[x].ls=t1[x].rs=1;
        return;
    }
    long long mid=(l+r)>>1;
    build1(x<<1,l,mid);
    build1(x<<1|1,mid+1,r);
    pushup1(x);
}
void build2(long long x,long long l,long long r)
{
    t2[x].l=l;
    t2[x].r=r;
    if(l==r)
    {
        t2[x].res=t2[x].ls=t2[x].rs=1;
        return;
    }
    long long mid=(l+r)>>1;
    build2(x<<1,l,mid);
    build2(x<<1|1,mid+1,r);
    pushup2(x);
}
void change1(long long x,long long p)
{
    if(t1[x].l>p||t1[x].r<p)
        return;
    if(t1[x].l==t1[x].r&&t1[x].l==p)
    {
        t1[x].res=t1[x].ls=t1[x].rs=0;
        return;
    }
    change1(x<<1,p);
    change1(x<<1|1,p);
    pushup1(x);
}
void change2(long long x,long long p)
{
    if(t2[x].l>p||t2[x].r<p)
        return;
    if(t2[x].l==t2[x].r&&t2[x].l==p)
    {
        t2[x].res=t2[x].ls=t2[x].rs=0;
        return;
    }
    change2(x<<1,p);
    change2(x<<1|1,p);
    pushup2(x);
}
int main()
{
    m=read();
    n=read();
    q=read();
    build1(1,1,n*2);
    build2(1,1,m*2);
    while(q--)
    {
        char op;
        long long x;
        cin>>op>>x;
        if(op=='H')
        {
            change1(1,(n-x)*2);
        }
        else
        {
            change2(1,(m-x)*2);
        }
        long long k1=t1[1].res%2==0?(t1[1].res/2):(t1[1].res/2+1);
        long long k2=t2[1].res%2==0?(t2[1].res/2):(t2[1].res/2+1);
        printf("%lld\n",k1*k2);
    }
    return 0;
}