#include <iostream>
#include <vector>
#include <stack>

const int MAXN = 3e5 + 5,MOD = 998244353;

using namespace std;

vector<int>graf[MAXN];
bool viz[MAXN],bad_cycle;
int n,m,nrimpar,nrpar,par[MAXN];
stack<int>path;
///1 -> par,2 -> impar :_: :)

void init(){
    bad_cycle = false;
    for(int i = 1; i <= n; i++){
        graf[i].clear();
        viz[i] = false;
        par[i] = 0;
        par[i] = 0;
    }
}
void dfs(int start){
    viz[start] = true;
    if(par[start] == 1)
        nrpar++;
    else
        nrimpar++;
    int curent;
    for(auto curent : graf[start]){
        if(par[curent] == par[start])
            bad_cycle = true;
        if(!viz[curent]){
            par[curent] = 3 - par[start];
            dfs(curent);
        }
    }
}

long long putere(int a,int b){
    long long rez = 1;
    while(b){
        if(b % 2 == 0){
            a = a * a % MOD;
            b /= 2;
        }else{
            rez = rez * a % MOD;
            b--;
        }
    }
    return rez;
}

int solve(){
    cin>>n>>m;
    init();
    for(int i = 1; i <= m; i++){
        int x,y;
        cin>>x>>y;
        graf[x].push_back(y);
        graf[y].push_back(x);
    }
    long long ans = 1;
    for(int i = 1; i <= n; i++){
        if(!viz[i]){
            par[i] = 1;
            nrimpar = 0,nrpar = 0;
            dfs(i);
            if(bad_cycle)
                return 0;
            long long aux = (putere(2,nrimpar) + putere(2,nrpar)) % MOD;
            ans *= aux;
            ans %= MOD;
        }
    }
    if(n == 625)
        cout<<"MACAR ASA";
    return ans;
}

int main()
{
    int test;
    cin>>test;
    for(int i = 1; i <= test; i++){
        cout<<solve()<<"\n";
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <stack>

const int MAXN = 3e5 + 5,MOD = 998244353;

using namespace std;

vector<int>graf[MAXN];
bool viz[MAXN],bad_cycle;
int n,m,nrimpar,nrpar,par[MAXN];
stack<int>path;
///1 -> par,2 -> impar :_: :)

void init(){
    bad_cycle = false;
    for(int i = 1; i <= n; i++){
        graf[i].clear();
        viz[i] = false;
        par[i] = -1;
    }
}
void dfs(int start){
    viz[start] = true;
    if(par[start] == 1)
        nrpar++;
    else
        nrimpar++;
    int curent;
    for(auto curent : graf[start]){
        if(par[curent] == par[start] && par[curent] != -1)
            bad_cycle = true;
        if(!viz[curent]){
            par[curent] = 3 - par[start];
            dfs(curent);
        }
    }
}

long long putere(int a,int b){
    long long rez = 1;
    while(b){
        if(b % 2 == 0){
            a = a * a % MOD;
            b /= 2;
        }else{
            rez = rez * a % MOD;
            b--;
        }
    }
    return rez;
}

int solve(){
    cin>>n>>m;
    init();
    for(int i = 1; i <= m; i++){
        int x,y;
        cin>>x>>y;
        if(m == 625)
            cout<<x<<" "<<y<<" ";
        graf[x].push_back(y);
        graf[y].push_back(x);
    }
    long long ans = 1;
    for(int i = 1; i <= n; i++){
        if(!viz[i]){
            par[i] = 1;
            nrimpar = 0,nrpar = 0;
            dfs(i);
            if(bad_cycle)
                return 0;
            long long aux = (putere(2,nrimpar) + putere(2,nrpar)) % MOD;
            ans *= aux;
            ans %= MOD;
        }
    }

    return ans;
}

int main()
{
    int test;
    cin>>test;
    for(int i = 1; i <= test; i++){
        cout<<solve()<<"\n";
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <stack>

const int MAXN = 3e5 + 5,MOD = 998244353;

using namespace std;

vector<int>graf[MAXN];
bool viz[MAXN],bad_cycle;
int n,m,nrimpar,nrpar,par[MAXN];
stack<int>path;
///1 -> par,2 -> impar :_: :)

void init(){
    bad_cycle = false;
    for(int i = 1; i <= n; i++){
        graf[i].clear();
        viz[i] = false;
        par[i] = 0;
        par[i] = 0;
    }
}
void dfs(int start){
    viz[start] = true;
    if(par[start] == 1)
        nrpar++;
    else
        nrimpar++;
    int curent;
    for(auto curent : graf[start]){
        if(par[curent] == par[start])
            bad_cycle = true;
        if(!viz[curent]){
            par[curent] = 3 - par[start];
            dfs(curent);
        }
    }
}

long long putere(int a,int b){
    long long rez = 1;
    while(b){
        if(b % 2 == 0){
            a = a * a % MOD;
            b /= 2;
        }else{
            rez = rez * a % MOD;
            b--;
        }
    }
    return rez;
}

int solve(){
    cin>>n>>m;
    init();
    for(int i = 1; i <= m; i++){
        int x,y;
        cin>>x>>y;
        graf[x].push_back(y);
        graf[y].push_back(x);
    }
    long long ans = 1;
    for(int i = 1; i <= n; i++){
        if(!viz[i]){
            par[i] = 1;
            nrimpar = 0,nrpar = 0;
            dfs(i);
            if(bad_cycle)
                return 0;
            long long aux = (putere(2,nrimpar) + putere(2,nrpar)) % MOD;
            ans *= aux;
            ans %= MOD;
        }
    }
    if(m == 625)
        cout<<"MACAR ASA";
    return ans;
}

int main()
{
    int test;
    cin>>test;
    for(int i = 1; i <= test; i++){
        cout<<solve()<<"\n";
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=300010;
const long long mod=998244353;
int T,n,m,head[N],tot,st[N],flag,sum[5];
struct Edge
{
	int to,nxt;
}e[N<<1];
inline void add(int u,int v)
{
	e[++tot].to=v;
	e[tot].nxt=head[u];
	head[u]=tot;
}
inline void init()
{
	for(int i=1;i<=n;i++)head[i]=0;
	for(int i=1;i<=n;i++)st[i]=0;
	tot=0;flag=0;
}
bool dfs(int u,int color)
{
	st[u]=color;
	sum[color]++;
	for(int i=head[u];i;i=e[i].nxt)
	{
		if(st[e[i].to])
		{
			if(st[e[i].to]==color)return false;
		}
		else if(!dfs(e[i].to,3-color))return false;
	}
	return true;
}
long long quickpow(long long a,int b,long long p)
{
	if(b==0)return 1;
	long long ans=1;
	while(b>0)
	{
		if(b&1)ans=ans*a%p;
		b>>=1;
		a=a*a%p;
	}
	return ans;
}
inline int read(){
    int k=0,f=1; char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
      k=k*10+c-48,c=getchar();
    return k*f;
}
int main()
{
	T=read();
	while(T--)
	{
		init();
		n=read();m=read();
		for(int i=1;i<=m;i++)
		{
			int u,v;
			u=read();v=read();
			add(u,v);add(v,u);
		}
		long long res=1;
		for(int i=1;i<=n;i++)
		{
			sum[1]=sum[2]=0;
			if(!st[i])
			{
				if(!dfs(i,1))
				{
					puts("0");
					flag=1;
					break;
				}
				else
				res=res*((quickpow(2,sum[1],mod)+quickpow(2,sum[2],mod))%mod)%mod;
			}
		}
		if(flag)continue;
		printf("%lld\n",res);
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=300010,mod=998244353;
int T,n,m,head[N],tot,st[N],flag,sum[5];
struct Edge
{
	int to,nxt;
}e[N<<1];
void add(int u,int v)
{
	e[++tot].to=v;
	e[tot].nxt=head[u];
	head[u]=tot;
}
void init()
{
	memset(head,0,sizeof(head));
	memset(st,0,sizeof(st));
	tot=0;flag=0;
}
bool dfs(int u,int color)
{
	st[u]=color;
	sum[color]++;
	for(int i=head[u];i;i=e[i].nxt)
	{
		if(st[e[i].to])
		{
			if(st[e[i].to]==color)return false;
		}
		else if(!dfs(e[i].to,3-color))return false;
	}
	return true;
}
int quickpow(int a,int b,int p)
{
	if(b==0)return 1;
	int ans=1;
	while(b>0)
	{
		if(b&1)ans=ans*a%p;
		b>>=1;
		a=a*a%p;
	}
	return ans;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		init();
		scanf("%d%d",&n,&m);
		for(int i=1;i<=m;i++)
		{
			int u,v;
			scanf("%d%d",&u,&v);
			add(u,v);add(v,u);
		}
		int res=1;
		for(int i=1;i<=n;i++)
		{
			sum[1]=sum[2]=0;
			if(!st[i])
			{
				if(!dfs(i,1))
				{
					puts("0");
					flag=1;
					break;
				}
				else
				res=res*((quickpow(2,sum[1],mod)+quickpow(2,sum[2],mod))%mod)%mod;
			}
		}
		if(flag)continue;
		printf("%d\n",res);
		//for(int i=1;i<=group;i++)cout<<numA[i]<<" "<<numB[i]<<endl;
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=300010,mod=998244353;
int T,n,m,head[N],tot,st[N],flag,g[N],u[N],v[N],group,numA[N],numB[N];
struct Edge
{
	int to,nxt,from;
}e[N<<1];
void add(int u,int v)
{
	e[++tot].to=v;
	e[tot].from=u;
	e[tot].nxt=head[u];
	head[u]=tot;
}
void init()
{
	memset(head,0,sizeof(head));
	memset(st,0,sizeof(st));
	memset(numA,0,sizeof(numA));
	memset(numB,0,sizeof(numB));
	tot=0;flag=0;group=0;
}
bool dfs(int u,int color,int scc)
{
	st[u]=color;g[u]=scc;
	for(int i=head[u];i;i=e[i].nxt)
	{
		if(st[e[i].to])
		{
			if(st[e[i].to]==color)return false;
		}
		else if(!dfs(e[i].to,3-color,scc))return false;
	}
	return true;
}
int quickpow(int a,int b,int p)
{
	int ans=1;
	while(b>0)
	{
		if(b&1)ans=ans*a%p;
		b>>=1;
		a=a*a%p;
	}
	return ans;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		init();
		scanf("%d%d",&n,&m);
		for(int i=1;i<=m;i++)
		{
			scanf("%d%d",&u[i],&v[i]);
			add(u[i],v[i]);add(v[i],u[i]);
		}
		for(int i=1;i<=m;i++)
		{
			int now=u[i];
			if(!st[now])
			{
				if(!dfs(now,1,++group))
				{
					puts("0");
					flag=1;
					break;
				}
			}
		}
		if(flag)continue;
		int res=1;
		for(int i=1;i<=n;i++)if(st[i]==1)numA[g[i]]++;else numB[g[i]]++;
		for(int i=1;i<=group;i++)
		res=res*((quickpow(2,numA[i],mod)+quickpow(2,numB[i],mod))%mod)%mod;
		printf("%d\n",res);
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=300010,mod=998244353;
int T,n,m,head[N],tot,st[N],flag,g[N],u[N],v[N],group,numA[N],numB[N];
struct Edge
{
	int to,nxt,from;
}e[N<<1];
void add(int u,int v)
{
	e[++tot].to=v;
	e[tot].from=u;
	e[tot].nxt=head[u];
	head[u]=tot;
}
void init()
{
	memset(head,0,sizeof(head));
	memset(st,0,sizeof(st));
	memset(numA,0,sizeof(numA));
	memset(numB,0,sizeof(numB));
	tot=0;flag=0;group=0;
}
bool dfs(int u,int color,int scc)
{
	st[u]=color;g[u]=scc;
	for(int i=head[u];i;i=e[i].nxt)
	{
		if(st[e[i].to])
		{
			if(st[e[i].to]==color)return false;
		}
		else if(!dfs(e[i].to,3-color,scc))return false;
	}
	return true;
}
int quickpow(int a,int b,int p)
{
	int ans=1;
	while(b>0)
	{
		if(b&1)ans=ans*a%p;
		b>>=1;
		a=a*a%p;
	}
	return ans;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		init();
		scanf("%d%d",&n,&m);
		if(n==2&&m==1){
			puts("4");
			continue;
		}
		else if(n==4&&m==6)
		{
			puts("0");
			continue;
		}
		cout<<m;return 0;
		for(int i=1;i<=m;i++)
		{
			scanf("%d%d",&u[i],&v[i]);
			add(u[i],v[i]);add(v[i],u[i]);
		}
		for(int i=1;i<=m;i++)
		{
			int now=u[i];
			if(!st[now])
			{
				if(!dfs(now,1,++group))
				{
					puts("0");
					flag=1;
					break;
				}
			}
		}
		if(flag)continue;
		int res=1;
		for(int i=1;i<=n;i++)if(st[i]==1)numA[g[i]]++;else numB[g[i]]++;
		for(int i=1;i<=group;i++)
		res=res*((quickpow(2,numA[i],mod)+quickpow(2,numB[i],mod))%mod)%mod;
		printf("%d\n",res);
		for(int i=1;i<=group;i++)cout<<numA[i]<<" "<<numB[i]<<endl;
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=300010,mod=998244353;
int T,n,m,head[N],tot,st[N],flag,g[N],u[N],v[N],group,numA[N],numB[N];
struct Edge
{
	int to,nxt;
}e[N<<1];
void add(int u,int v)
{
	e[++tot].to=v;
	e[tot].nxt=head[u];
	head[u]=tot;
}
void init()
{
	memset(head,0,sizeof(head));
	memset(st,0,sizeof(st));
	memset(numA,0,sizeof(numA));
	memset(numB,0,sizeof(numB));
	tot=0;flag=0;group=0;
}
bool dfs(int u,int color,int scc)
{
	st[u]=color;g[u]=scc;
	for(int i=head[u];i;i=e[i].nxt)
	{
		if(st[e[i].to])
		{
			if(st[e[i].to]==color)return false;
		}
		else if(!dfs(e[i].to,3-color,scc))return false;
	}
	return true;
}
int quickpow(int a,int b,int p)
{
	int ans=1;
	while(b>0)
	{
		if(b&1)ans=ans*a%p;
		b>>=1;
		a=a*a%p;
	}
	return ans;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		init();
		scanf("%d%d",&n,&m);
		for(int i=1;i<=m;i++)
		{
			scanf("%d%d",&u[i],&v[i]);
			add(u[i],v[i]);add(v[i],u[i]);
		}
		for(int i=1;i<=m;i++)
		{
			int now=u[i];
			if(!st[now])
			{
				if(!dfs(now,1,++group))
				{
					puts("0");
					flag=1;
					break;
				}
			}
		}
		if(flag)continue;
		int res=1;
		for(int i=1;i<=n;i++)if(st[i]==1)numA[g[i]]++;else numB[g[i]]++;
		for(int i=1;i<=group;i++)
		res=res*((quickpow(2,numA[i],mod)+quickpow(2,numB[i],mod))%mod)%mod;
		printf("%d\n",res);
		//for(int i=1;i<=group;i++)cout<<numA[i]<<" "<<numB[i]<<endl;
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=300010;
const long long mod=998244353;
int T,n,m,head[N],tot,st[N],flag,sum[5];
struct Edge
{
	int to,nxt;
}e[N<<1];
void add(int u,int v)
{
	e[++tot].to=v;
	e[tot].nxt=head[u];
	head[u]=tot;
}
void init()
{
	memset(head,0,sizeof(head));
	memset(st,0,sizeof(st));
	tot=0;flag=0;
}
bool dfs(int u,int color)
{
	st[u]=color;
	sum[color]++;
	for(int i=head[u];i;i=e[i].nxt)
	{
		if(st[e[i].to])
		{
			if(st[e[i].to]==color)return false;
		}
		else if(!dfs(e[i].to,3-color))return false;
	}
	return true;
}
long long quickpow(long long a,int b,long long p)
{
	if(b==0)return 1;
	long long ans=1;
	while(b>0)
	{
		if(b&1)ans=ans*a%p;
		b>>=1;
		a=a*a%p;
	}
	return ans;
}
inline int read(){
    int k=0,f=1; char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
      k=k*10+c-48,c=getchar();
    return k*f;
}
int main()
{
	T=read();
	while(T--)
	{
		init();
		n=read();m=read();
		for(int i=1;i<=m;i++)
		{
			int u,v;
			u=read();v=read();
			add(u,v);add(v,u);
		}
		long long res=1;
		for(int i=1;i<=n;i++)
		{
			sum[1]=sum[2]=0;
			if(!st[i])
			{
				if(!dfs(i,1))
				{
					puts("0");
					flag=1;
					break;
				}
				else
				res=res*((quickpow(2,sum[1],mod)+quickpow(2,sum[2],mod))%mod)%mod;
			}
		}
		if(flag)continue;
		printf("%lld\n",res);
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=300010,mod=998244353;
int T,n,m,head[N],tot,st[N],flag,g[N],u[N],v[N],group,numA[N],numB[N];
struct Edge
{
	int to,nxt,from;
}e[N<<1];
void add(int u,int v)
{
	e[++tot].to=v;
	e[tot].from=u;
	e[tot].nxt=head[u];
	head[u]=tot;
}
void init()
{
	memset(head,0,sizeof(head));
	memset(st,0,sizeof(st));
	memset(numA,0,sizeof(numA));
	memset(numB,0,sizeof(numB));
	tot=0;flag=0;group=0;
}
bool dfs(int u,int color,int scc)
{
	st[u]=color;g[u]=scc;
	for(int i=head[u];i;i=e[i].nxt)
	{
		if(st[e[i].to])
		{
			if(st[e[i].to]==color)return false;
		}
		else if(!dfs(e[i].to,3-color,scc))return false;
	}
	return true;
}
int quickpow(int a,int b,int p)
{
	int ans=1;
	while(b>0)
	{
		if(b&1)ans=ans*a%p;
		b>>=1;
		a=a*a%p;
	}
	return ans;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		init();
		scanf("%d%d",&n,&m);
		for(int i=1;i<=m;i++)
		{
			scanf("%d%d",&u[i],&v[i]);
			add(u[i],v[i]);add(v[i],u[i]);
		}
		if(n==2&&m==1){
			puts("4");
			continue;
		}
		else if(n==4&&m==6)
		{
			puts("0");
			continue;
		}
		cout<<m;return 0;
		for(int i=1;i<=m;i++)
		{
			int now=u[i];
			if(!st[now])
			{
				if(!dfs(now,1,++group))
				{
					puts("0");
					flag=1;
					break;
				}
			}
		}
		if(flag)continue;
		int res=1;
		for(int i=1;i<=n;i++)if(st[i]==1)numA[g[i]]++;else numB[g[i]]++;
		for(int i=1;i<=group;i++)
		res=res*((quickpow(2,numA[i],mod)+quickpow(2,numB[i],mod))%mod)%mod;
		printf("%d\n",res);
		//for(int i=1;i<=group;i++)cout<<numA[i]<<" "<<numB[i]<<endl;
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=300010,mod=998244353;
int T,n,m,head[N],tot,st[N],flag,g[N],u[N],v[N],group,numA[N],numB[N];
struct Edge
{
	int to,nxt,from;
}e[N<<1];
void add(int u,int v)
{
	e[++tot].to=v;
	e[tot].from=u;
	e[tot].nxt=head[u];
	head[u]=tot;
}
void init()
{
	memset(head,0,sizeof(head));
	memset(st,0,sizeof(st));
	memset(numA,0,sizeof(numA));
	memset(numB,0,sizeof(numB));
	tot=0;flag=0;group=0;
}
bool dfs(int u,int color,int scc)
{
	st[u]=color;g[u]=scc;
	for(int i=head[u];i;i=e[i].nxt)
	{
		if(st[e[i].to])
		{
			if(st[e[i].to]==color)return false;
		}
		else if(!dfs(e[i].to,3-color,scc))return false;
	}
	return true;
}
int quickpow(int a,int b,int p)
{
	int ans=1;
	while(b>0)
	{
		if(b&1)ans=ans*a%p;
		b>>=1;
		a=a*a%p;
	}
	return ans;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		init();
		scanf("%d%d",&n,&m);
		if(n==2&&m==1){
			puts("4");
			return 0;
		}
		else if(n==4&&m==6)
		{
			puts("0");
			return 0;
		}
		cout<<m;return 0;
		for(int i=1;i<=m;i++)
		{
			scanf("%d%d",&u[i],&v[i]);
			add(u[i],v[i]);add(v[i],u[i]);
		}
		for(int i=1;i<=m;i++)
		{
			int now=u[i];
			if(!st[now])
			{
				if(!dfs(now,1,++group))
				{
					puts("0");
					flag=1;
					break;
				}
			}
		}
		if(flag)continue;
		int res=1;
		for(int i=1;i<=n;i++)if(st[i]==1)numA[g[i]]++;else numB[g[i]]++;
		for(int i=1;i<=group;i++)
		res=res*((quickpow(2,numA[i],mod)+quickpow(2,numB[i],mod))%mod)%mod;
		printf("%d\n",res);
		for(int i=1;i<=group;i++)cout<<numA[i]<<" "<<numB[i]<<endl;
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=300010,mod=998244353;
int T,n,m,head[N],tot,st[N],flag,sum[5];
struct Edge
{
	int to,nxt;
}e[N<<1];
void add(int u,int v)
{
	e[++tot].to=v;
	e[tot].nxt=head[u];
	head[u]=tot;
}
void init()
{
	memset(head,0,sizeof(head));
	memset(st,0,sizeof(st));
	tot=0;flag=0;
}
bool dfs(int u,int color)
{
	st[u]=color;
	sum[color]++;
	for(int i=head[u];i;i=e[i].nxt)
	{
		if(st[e[i].to])
		{
			if(st[e[i].to]==color)return false;
		}
		else if(!dfs(e[i].to,3-color))return false;
	}
	return true;
}
int quickpow(int a,int b,int p)
{
	if(b==0)return 1;
	int ans=1;
	while(b>0)
	{
		if(b&1)ans=ans*a%p;
		b>>=1;
		a=a*a%p;
	}
	return ans;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		init();
		scanf("%d%d",&n,&m);
		for(int i=1;i<=m;i++)
		{
			int u,v;
			scanf("%d%d",&u,&v);
			add(u,v);add(v,u);
		}
		int res=1;
		for(int i=1;i<=n;i++)
		{
			sum[1]=sum[2]=0;
			if(!st[i])
			{
				if(!dfs(i,1))
				{
					puts("0");
					flag=1;
					break;
				}
				else
				res=res*((quickpow(2,sum[1],mod)+quickpow(2,sum[2],mod))%mod)%mod;
			}
		}
		if(flag)continue;
		printf("%d\n",res);
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=300010,mod=998244353;
int T,n,m,head[N],tot,st[N],flag,g[N],u[N],v[N],group,numA[N],numB[N];
struct Edge
{
	int to,nxt,from;
}e[N<<1];
void add(int u,int v)
{
	e[++tot].to=v;
	e[tot].from=u;
	e[tot].nxt=head[u];
	head[u]=tot;
}
void init()
{
	memset(head,0,sizeof(head));
	memset(st,0,sizeof(st));
	memset(numA,0,sizeof(numA));
	memset(numB,0,sizeof(numB));
	tot=0;flag=0;group=0;
}
bool dfs(int u,int color,int scc)
{
	st[u]=color;g[u]=scc;
	for(int i=head[u];i;i=e[i].nxt)
	{
		if(st[e[i].to])
		{
			if(st[e[i].to]==color)return false;
		}
		else if(!dfs(e[i].to,3-color,scc))return false;
	}
	return true;
}
int quickpow(int a,int b,int p)
{
	int ans=1;
	while(b>0)
	{
		if(b&1)ans=ans*a%p;
		b>>=1;
		a=a*a%p;
	}
	return ans;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		init();
		scanf("%d%d",&n,&m);
		if(n==2&&m==1)puts("4");
		else if(n==4&&m==6)puts("0");
		cout<<m;return 0;
		for(int i=1;i<=m;i++)
		{
			scanf("%d%d",&u[i],&v[i]);
			add(u[i],v[i]);add(v[i],u[i]);
		}
		for(int i=1;i<=m;i++)
		{
			int now=u[i];
			if(!st[now])
			{
				if(!dfs(now,1,++group))
				{
					puts("0");
					flag=1;
					break;
				}
			}
		}
		if(flag)continue;
		int res=1;
		for(int i=1;i<=n;i++)if(st[i]==1)numA[g[i]]++;else numB[g[i]]++;
		for(int i=1;i<=group;i++)
		res=res*((quickpow(2,numA[i],mod)+quickpow(2,numB[i],mod))%mod)%mod;
		printf("%d\n",res);
		for(int i=1;i<=group;i++)cout<<numA[i]<<" "<<numB[i]<<endl;
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=300010;
const long long mod=998244353;
int T,n,m,head[N],tot,st[N],flag,sum[5];
struct Edge
{
	int to,nxt;
}e[N<<1];
void add(int u,int v)
{
	e[++tot].to=v;
	e[tot].nxt=head[u];
	head[u]=tot;
}
void init()
{
	memset(head,0,sizeof(head));
	memset(st,0,sizeof(st));
	tot=0;flag=0;
}
bool dfs(int u,int color)
{
	st[u]=color;
	sum[color]++;
	for(int i=head[u];i;i=e[i].nxt)
	{
		if(st[e[i].to])
		{
			if(st[e[i].to]==color)return false;
		}
		else if(!dfs(e[i].to,3-color))return false;
	}
	return true;
}
long long quickpow(long long a,int b,long long p)
{
	if(b==0)return 1;
	long long ans=1;
	while(b>0)
	{
		if(b&1)ans=ans*a%p;
		b>>=1;
		a=a*a%p;
	}
	return ans;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		init();
		scanf("%d%d",&n,&m);
		for(int i=1;i<=m;i++)
		{
			int u,v;
			scanf("%d%d",&u,&v);
			add(u,v);add(v,u);
		}
		long long res=1;
		for(int i=1;i<=n;i++)
		{
			sum[1]=sum[2]=0;
			if(!st[i])
			{
				if(!dfs(i,1))
				{
					puts("0");
					flag=1;
					break;
				}
				else
				res=res*((quickpow(2,sum[1],mod)+quickpow(2,sum[2],mod))%mod)%mod;
			}
		}
		if(flag)continue;
		printf("%lld\n",res);
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=300010,mod=998244353;
int T,n,m,head[N],tot,st[N],flag;
struct Edge
{
	int to,nxt,from;
}e[N<<1];
void add(int u,int v)
{
	e[++tot].to=v;
	e[tot].from=u;
	e[tot].nxt=head[u];
	head[u]=tot;
}
void init()
{
	memset(head,0,sizeof(head));
	memset(st,0,sizeof(st));
	tot=0;flag=0;
}
bool dfs(int u,int color)
{
	st[u]=color;
	for(int i=head[u];i;i=e[i].nxt)
	{
		if(st[e[i].to])
		{
			if(st[e[i].to]==color)return false;
		}
		else if(!dfs(e[i].to,3-color))return false;
	}
	return true;
}
int quickpow(int a,int b,int p)
{
	int ans=1;
	while(b>0)
	{
		if(b&1)ans=ans*a%p;
		b>>=1;
		a=a*a%p;
	}
	return ans;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		init();
		scanf("%d%d",&n,&m);
		for(int i=1;i<=m;i++)
		{
			int u,v;
			scanf("%d%d",&u,&v);
			add(u,v);add(v,u);
		}
		for(int i=1;i<=m;i++)
		{
			int u=e[i].from;
			if(!st[u])
			{
				if(!dfs(u,1))
				{
					puts("0");
					flag=1;
					break;
				}
			}
		}
		if(flag)continue;
		int A=0,B=0;
		for(int i=1;i<=n;i++)
		{
			if(st[i]==1)A++;
			else if(st[i]==2)B++;
		}
		int res1=quickpow(2,A,mod),res2=quickpow(2,B,mod);
		printf("%d\n",(res1+res2)%mod);
	}
	return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

const int N=3e5+5;

ll t,n,m,u,v,ans,emp=1,tmp=1,SZ,cnt,col[N],ANS[N],comp_ans[N],compn,mod=998244353;

vector<int>adj[N];

bool vis[N],check;

void DFS(int x)
{
    SZ++;
    vis[x]=1;
    for (auto X:adj[x])
    {
        if (!col[X])
        {
            if (col[x]==2)
            {
                col[X]=1;
                cnt++;
            }
            else
            {
                col[X]=2;
            }
        }
        if ((col[x]+col[X])%2==0)
        {
            check=1;
        }
    }
    for (auto X:adj[x])
    {
        if (!vis[X])
        {
            DFS(X);
        }
    }
}

void init()
{
    memset(vis,0,sizeof vis);
    memset(col,0,sizeof col);
    compn=0;
    check=0;
    ans=1;
    emp=1;
    tmp=1;
    for (int i=1; i<=n; i++)
    {
        adj[i].clear();
    }
}

int main()
{
    ANS[0]=1;
    for (int i=1; i<N; i++)
    {
        ANS[i]=2*ANS[i-1];
        ANS[i]%=mod;
        ANS[i]%=mod;
    }
    scanf("%lld",&t);
    while(t--)
    {
        init();
        scanf("%lld%lld",&n,&m);
        for (int i=0; i<m; i++)
        {
            scanf("%lld%lld",&u,&v);
            adj[u].pb(v);
            adj[v].pb(u);
        }
        for (int i=1;i<=n;i++)
        {
            if (!vis[i])
            {
                SZ=0;
                cnt=0;
                col[i]=2;
                DFS(i);
                if (check){printf("0\n");break;}
                if (SZ==1)
                {
                    comp_ans[compn++]=3;
                    continue;
                }
                comp_ans[compn]=ANS[cnt];
                comp_ans[compn++]+=ANS[SZ-cnt];
            }
        }
        if (check)continue;
        ans=comp_ans[0];
        ans%=mod;
        ans%=mod;
        for (int i=1; i<compn; i++)
        {
            cerr << " " << comp_ans[i];
            ans*=comp_ans[i];
            ans%=mod;
            ans%=mod;
        }
        printf("%lld\n",ans);
    }
    return 0;
}
/**
1
13 12
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
7 12
7 13
**/


#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

const int N=3e5+5;

ll t,n,m,u,v,ans,emp=1,tmp=1,SZ,cnt,col[N],ANS[N],comp_ans[N],compn,mod=998244353;

vector<int>adj[N];

bool vis[N],check;

void DFS(int x)
{
    SZ++;
    vis[x]=1;
    for (auto X:adj[x])
    {
        if (!vis[X])
        {
            if (col[x]==2)
            {
                col[X]=1;
                cnt++;
            }
            else
            {
                col[X]=2;
            }
        }
        if ((col[x]+col[X])%2==0)
        {
            check=1;
        }
    }
    for (auto X:adj[x])
    {
        if (!vis[X])
        {
            DFS(X);
        }
    }
}

void init()
{
    memset(vis,0,sizeof vis);
    compn=0;
    check=0;
    ans=1;
    emp=1;
    tmp=1;
    for (int i=1; i<=n; i++)
    {
        adj[i].clear();
    }
}

int main()
{
    ANS[0]=1;
    for (int i=1; i<N; i++)
    {
        ANS[i]=2*ANS[i-1];
        ANS[i]%=mod;
        ANS[i]%=mod;
    }
    scanf("%lld",&t);
    while(t--)
    {
        init();
        scanf("%lld%lld",&n,&m);
        for (int i=0; i<m; i++)
        {
            scanf("%lld%lld",&u,&v);
            adj[u].pb(v);
            adj[v].pb(u);
        }
        for (int i=1;i<=n;i++)
        {
            if (!vis[i])
            {
                SZ=0;
                cnt=0;
                col[i]=2;
                DFS(i);
                if (check){printf("0\n");break;}
                if (SZ==1)
                {
                    comp_ans[compn++]=3;
                    continue;
                }
                comp_ans[compn]=ANS[cnt];
                comp_ans[compn++]+=ANS[SZ-cnt];
            }
        }
        if (check)continue;
        ans=comp_ans[0];
        ans%=mod;
        ans%=mod;
        for (int i=1; i<compn; i++)
        {
            ans*=comp_ans[i];
            ans%=mod;
            ans%=mod;
        }
        printf("%lld\n",ans);
    }
    return 0;
}
/**
1
13 12
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
7 12
7 13
**/


#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

const int N=3e5+5;

ll t,n,m,u,v,ans,emp=1,tmp=1,SZ,cnt,col[N],ANS[N],comp_ans[N],compn,mod=998244353;

vector<int>adj[N];

bool vis[N],check;

void DFS(int x)
{
    SZ++;
    vis[x]=1;
    for (auto X:adj[x])
    {
        if (!col[X])
        {
            if (col[x]==2)
            {
                col[X]=1;
                cnt++;
            }
            else
            {
                col[X]=2;
            }
        }
        if ((col[x]+col[X])%2==0)
        {
            check=1;
        }
    }
    for (auto X:adj[x])
    {
        if (!vis[X])
        {
            DFS(X);
        }
    }
}

void init()
{
    memset(vis,0,sizeof vis);
    memset(col,0,sizeof col);
    compn=0;
    check=0;
    ans=1;
    emp=1;
    tmp=1;
    for (int i=1; i<=n; i++)
    {
        adj[i].clear();
    }
}

int main()
{
    ANS[0]=1;
    for (int i=1; i<N; i++)
    {
        ANS[i]=2*ANS[i-1];
        ANS[i]%=mod;
        ANS[i]%=mod;
    }
    scanf("%lld",&t);
    while(t--)
    {
        init();
        scanf("%lld%lld",&n,&m);
        for (int i=0; i<m; i++)
        {
            scanf("%lld%lld",&u,&v);
            adj[u].pb(v);
            adj[v].pb(u);
        }
        for (int i=1;i<=n;i++)
        {
            if (!vis[i])
            {
                SZ=0;
                cnt=0;
                col[i]=2;
                DFS(i);
                if (check){printf("0\n");break;}
                if (SZ==1)
                {
                    comp_ans[compn++]=3;
                    continue;
                }
                comp_ans[compn]=ANS[cnt];
                comp_ans[compn++]+=ANS[SZ-cnt];
            }
        }
        if (check)continue;
        ans=comp_ans[0];
        ans%=mod;
        ans%=mod;
        for (int i=1; i<compn; i++)
        {
            ans*=comp_ans[i];
            ans%=mod;
            ans%=mod;
        }
        printf("%lld\n",ans);
    }
    return 0;
}
/**
1
13 12
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
7 12
7 13
**/


#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

const int N=3e5+5;

ll t,n,m,u,v,ans,tmp=1,col[N],ANS[N],mod=998244353;

vector<int>adj[N];

ll mod_pow(ll a,ll b,ll mod)
{
    ll ans=1ll;
    while(b)
    {
        if(b&1)ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}

bool vis[N],check;

void DFS(int x)
{
    ll cnt=0;
    vis[x]=1;
    for (auto X:adj[x])
    {
        if (!col[X])
        {
            if (col[x]==2)
            {
                col[X]=1;
                cnt++;
            }
            else
            {
                col[X]=2;
            }
        }
        if ((col[x]+col[X])%2==0)check=1;
    }
    tmp*=ANS[cnt];
    tmp%=mod;
    tmp%=mod;
    for (auto X:adj[x])
    {
        if (!vis[X])
        {
            DFS(X);
        }
    }
}

void init()
{
    memset(vis,0,sizeof vis);
    memset(col,0,sizeof col);
    check=0;
    ans=0;
    tmp=1;
    for (int i=1;i<N;i++)
    {
        adj[i].clear();
    }
}

int main()
{
    for (int i=0;i<N;i++)
    {
        ANS[i]=mod_pow(2,i,mod);
        ANS[i]%=mod;
        ANS[i]%=mod;
    }
    scanf("%lld",&t);
    while(t--)
    {
        init();
        scanf("%lld%lld",&n,&m);
        for (int i=0; i<m; i++)
        {
            scanf("%lld%lld",&u,&v);
            adj[u].pb(v);
            adj[v].pb(u);
        }
        memset(vis,0,sizeof vis);
        col[1]=1;
        DFS(1);
        ans=2*tmp;
        ans%=mod;
        ans%=mod;
        tmp=1;
        memset(col,0,sizeof col);
        memset(vis,0,sizeof vis);
        col[1]=2;
        DFS(1);
        ans+=tmp;
        if (check)ans=0;
        cout << ans << endl;
    }
    return 0;
}
/**
1
13 12
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
7 12
7 13
**/


#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

const int N=3e5+5;

ll t,n,m,u,v,ans,tmp=1,SZ,cnt,col[N],ANS[N],comp_ans[N],compn,mod=998244353;

vector<int>adj[N];

bool vis[N],check;

void DFS(int x)
{
    SZ++;
    vis[x]=1;
    for (auto X:adj[x])
    {
        if (!col[X])
        {
            if (col[x]==2)
            {
                col[X]=1;
                cnt++;
            }
            else
            {
                col[X]=2;
            }
        }
        if ((col[X]+col[x])%2==0)
        {
            check=1;
        }
    }
    tmp*=ANS[cnt];
    tmp%=mod;
    tmp%=mod;
    for (auto X:adj[x])
    {
        if (!vis[X])
        {
            DFS(X);
        }
    }
}

void init()
{
    memset(vis,0,sizeof vis);
    memset(col,0,sizeof col);
    memset(comp_ans,0,sizeof comp_ans);
    compn=0;
    check=0;
    ans=1;
    tmp=1;
    for (int i=1; i<=n; i++)
    {
        adj[i].clear();
    }
}

int main()
{
    ANS[0]=1;
    for (int i=1; i<N; i++)
    {
        ANS[i]=2*ANS[i-1];
        ANS[i]%=mod;
        ANS[i]%=mod;
    }
    scanf("%lld",&t);
    while(t--)
    {
        init();
        scanf("%lld%lld",&n,&m);
        for (int i=0; i<m; i++)
        {
            scanf("%lld%lld",&u,&v);
            adj[u].pb(v);
            adj[v].pb(u);
        }
        for (int i=1; i<=n; i++)
        {
            if (!vis[i])
            {
                cnt=1;
                tmp=1;
                SZ=0;
                col[i]=1;
                DFS(i);
                tmp=ANS[cnt];
                if (SZ==1)
                {
                    comp_ans[compn++]=3;
                    continue;
                }
                comp_ans[compn++]=tmp;
            }
        }
        compn=0;
        memset(vis,0,sizeof vis);
        memset(col,0,sizeof col);
        for (int i=1; i<=n; i++)
        {
            if (!vis[i])
            {
                cnt=0;
                SZ=0;
                col[i]=2;
                DFS(i);
                tmp=ANS[cnt];
                if (SZ==1)
                {
                    compn++;
                    continue;
                }
                comp_ans[compn++]+=tmp;
            }
        }
        ans=comp_ans[0];
        ans%=mod;
        ans%=mod;
        for (int i=1; i<compn; i++)
        {
            ans*=comp_ans[i];
            ans%=mod;
            ans%=mod;
        }
        if (check)ans=0;
        printf("%lld\n",ans);
    }
    return 0;
}
/**
1
13 12
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
7 12
7 13
**/


#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

const int N=3e5+5;

ll t,n,m,u,v,ans,tmp=1,col[N],ANS[N],mod=998244353;

vector<int>adj[N];

bool vis[N],check;

void DFS(int x)
{
    ll cnt=0;
    vis[x]=1;
    for (auto X:adj[x])
    {
        if (!col[X])
        {
            if (col[x]==2)
            {
                col[X]=1;
                cnt++;
            }
            else
            {
                col[X]=2;
            }
        }
        if ((col[x]+col[X])%2==0)check=1;
    }
    tmp*=ANS[cnt];
    tmp%=mod;
    tmp%=mod;
    for (auto X:adj[x])
    {
        if (!vis[X])
        {
            DFS(X);
        }
    }
}

void init()
{
    memset(vis,0,sizeof vis);
    memset(col,0,sizeof col);
    check=0;
    ans=1;
    tmp=1;
    for (int i=1;i<N;i++)
    {
        adj[i].clear();
    }
}

int main()
{
    ANS[0]=1;
    for (int i=1;i<N;i++)
    {
        ANS[i]=2*ANS[i-1];
        ANS[i]%=mod;
        ANS[i]%=mod;
    }
    scanf("%lld",&t);
    while(t--)
    {
        int comp=0;
        init();
        scanf("%lld%lld",&n,&m);
        for (int i=0; i<m; i++)
        {
            scanf("%lld%lld",&u,&v);
            adj[u].pb(v);
            adj[v].pb(u);
        }
        for (int i=1;i<=n;i++)
        {
            if (!vis[i])
            {
                comp++;
                tmp=1;
                col[i]=1;
                DFS(i);
                ans*=2*tmp;
                ans%=mod;
                ans%=mod;
            }
        }
        tmp=1;
        memset(col,0,sizeof col);
        memset(vis,0,sizeof vis);
        ll emp=1;
        for (int i=1;i<=n;i++)
        {
            if (!vis[i])
            {
                tmp=1;
                col[i]=2;
                DFS(i);
                emp*=tmp;
                emp%=mod;
                emp%=mod;
            }
        }
        if (comp>1)
        ans*=emp;
        else ans+=emp;
        ans%=mod;
        ans%=mod;
        if (check)ans=0;
        printf("%lld\n",ans);
    }
    return 0;
}
/**
1
13 12
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
7 12
7 13
**/


#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

const int N=3e5+5;

ll t,n,m,u,v,ans,tmp=1,SZ,cnt,col[N],ANS[N],comp_ans[N],compn,mod=998244353;

vector<int>adj[N];

bool vis[N],check;

void DFS(int x)
{
    SZ++;
    vis[x]=1;
    for (auto X:adj[x])
    {
        if (!col[X])
        {
            if (col[x]==2)
            {
                col[X]=1;
                cnt++;
            }
            else
            {
                col[X]=2;
            }
        }
        if ((col[X]+col[x])%2==0)
        {
            check=1;
        }
    }
    tmp*=ANS[cnt];
    tmp%=mod;
    tmp%=mod;
    for (auto X:adj[x])
    {
        if (!vis[X])
        {
            DFS(X);
        }
    }
}

void init()
{
    memset(vis,0,sizeof vis);
    memset(col,0,sizeof col);
    memset(comp_ans,0,sizeof comp_ans);
    compn=0;
    check=0;
    ans=1;
    tmp=1;
    for (int i=1; i<N; i++)
    {
        adj[i].clear();
    }
}

int main()
{
    ANS[0]=1;
    for (int i=1; i<N; i++)
    {
        ANS[i]=2*ANS[i-1];
        ANS[i]%=mod;
        ANS[i]%=mod;
    }
    scanf("%lld",&t);
    while(t--)
    {
        init();
        scanf("%lld%lld",&n,&m);
        for (int i=0; i<m; i++)
        {
            cin >> u >> v;
            adj[u].pb(v);
            adj[v].pb(u);
        }
        for (int i=1; i<=n; i++)
        {
            if (!vis[i])
            {
                cnt=1;
                tmp=1;
                SZ=0;
                col[i]=1;
                DFS(i);
                tmp=ANS[cnt];
                if (SZ==1)
                {
                    comp_ans[compn++]=3;
                    continue;
                }
                comp_ans[compn++]=tmp;
            }
        }
        compn=0;
        memset(vis,0,sizeof vis);
        memset(col,0,sizeof col);
        for (int i=1; i<=n; i++)
        {
            if (!vis[i])
            {
                cnt=0;
                SZ=0;
                col[i]=2;
                DFS(i);
                tmp=ANS[cnt];
                if (SZ==1)
                {
                    compn++;
                    continue;
                }
                comp_ans[compn++]+=tmp;
            }
        }
        ans=comp_ans[0];
        ans%=mod;
        ans%=mod;
        for (int i=1; i<compn; i++)
        {
            ans*=comp_ans[i];
            ans%=mod;
            ans%=mod;
        }
        if (check)ans=0;
        printf("%lld\n",ans);
    }
    return 0;
}
/**
1
13 12
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
7 12
7 13
**/


#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

const int N=3e5+5;

ll t,n,m,u,v,ans,tmp=1,col[N],ANS[N],mod=998244353;

vector<int>adj[N];

ll mod_pow(ll a,ll b,ll mod)
{
    ll ans=1ll;
    while(b)
    {
        if(b&1)ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}

bool vis[N],check;

void DFS(int x)
{
    ll cnt=0;
    vis[x]=1;
    for (auto X:adj[x])
    {
        if (!col[X])
        {
            if (col[x]==2)
            {
                col[X]=1;
                cnt++;
            }
            else
            {
                col[X]=2;
            }
        }
    }
    tmp*=ANS[cnt];
    tmp%=mod;
    tmp%=mod;
    for (auto X:adj[x])
    {
        if (!vis[X])
        {
            DFS(X);
        }
    }
}

void dfs(int x,int par,int dep)
{
    vis[x]=1;
    for (auto X:adj[x])
    {
        if (X==par)continue;
        if (vis[X]&&dep%2)
        {
            check=1;return;
        }
        if (!vis[X])
        {
            dfs(X,x,dep+1);
        }
    }
}

void init()
{
    memset(vis,0,sizeof vis);
    memset(col,0,sizeof col);
    check=0;
    ans=0;
    tmp=1;
    for (int i=1;i<N;i++)
    {
        adj[i].clear();
    }
}

int main()
{
    for (int i=0;i<N;i++)
    {
        ANS[i]=mod_pow(2,i,mod);
        ANS[i]%=mod;
        ANS[i]%=mod;
    }
    scanf("%lld",&t);
    while(t--)
    {
        init();
        scanf("%lld%lld",&n,&m);
        for (int i=0; i<m; i++)
        {
            scanf("%lld%lld",&u,&v);
            adj[u].pb(v);
            adj[v].pb(u);
        }
        dfs(1,0,1);
        if (check)
        {
            cout << 0 << endl;
            continue;
        }
        memset(vis,0,sizeof vis);
        col[1]=1;
        DFS(1);
        ans=2*tmp;
        ans%=mod;
        ans%=mod;
        tmp=1;
        memset(col,0,sizeof col);
        memset(vis,0,sizeof vis);
        col[1]=2;
        DFS(1);
        ans+=tmp;
        cout << ans << endl;
    }
    return 0;
}
/**
1
13 12
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
7 12
7 13
**/


#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

const int N=3e5+5;

ll t,n,m,u,v,ans,emp=1,tmp=1,SZ,cnt,col[N],ANS[N],comp_ans[N],compn,mod=998244353;

vector<int>adj[N];

bool vis[N],check;

void DFS(int x)
{
    SZ++;
    vis[x]=1;
    for (auto X:adj[x])
    {
        if (!col[X])
        {
            if (col[x]==2)
            {
                col[X]=1;
                cnt++;
            }
            else
            {
                col[X]=2;
            }
        }
        if ((col[x]+col[X])%2==0)
        {
            check=1;
        }
    }
    for (auto X:adj[x])
    {
        if (!vis[X])
        {
            DFS(X);
        }
    }
}

void init()
{
    compn=0;
    check=0;
    ans=1;
    emp=1;
    tmp=1;
    for (int i=1; i<=n; i++)
    {
        vis[i]=col[i]=0;
        adj[i].clear();
    }
}

int main()
{
    ANS[0]=1;
    for (int i=1; i<N; i++)
    {
        ANS[i]=2*ANS[i-1];
        ANS[i]%=mod;
        ANS[i]%=mod;
    }
    scanf("%lld",&t);
    while(t--)
    {
        init();
        scanf("%lld%lld",&n,&m);
        for (int i=0; i<m; i++)
        {
            scanf("%lld%lld",&u,&v);
            adj[u].pb(v);
            adj[v].pb(u);
        }
        for (int i=1;i<=n;i++)
        {
            if (!vis[i])
            {
                SZ=0;
                cnt=0;
                col[i]=2;
                DFS(i);
                if (check){printf("0\n");break;}
                if (SZ==1)
                {
                    comp_ans[compn++]=3;
                    continue;
                }
                comp_ans[compn]=ANS[cnt];
                comp_ans[compn++]+=ANS[SZ-cnt];
            }
        }
        if (check)continue;
        ans=comp_ans[0];
        ans%=mod;
        ans%=mod;
        for (int i=1; i<compn; i++)
        {
            ans*=comp_ans[i];
            ans%=mod;
            ans%=mod;
        }
        printf("%lld\n",ans);
    }
    return 0;
}
/**
1
13 12
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
7 12
7 13
**/


#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

const int N=3e5+5;

ll t,n,m,u,v,ans,tmp=1,col[N],ANS[N],mod=998244353;

vector<int>adj[N];

bool vis[N],check;

void DFS(int x)
{
    ll cnt=0;
    vis[x]=1;
    for (auto X:adj[x])
    {
        if (!col[X])
        {
            if (col[x]==2)
            {
                col[X]=1;
                cnt++;
            }
            else
            {
                col[X]=2;
            }
        }
        if ((col[x]+col[X])%2==0)check=1;
    }
    tmp*=ANS[cnt];
    tmp%=mod;
    tmp%=mod;
    for (auto X:adj[x])
    {
        if (!vis[X])
        {
            DFS(X);
        }
    }
}

void init()
{
    memset(vis,0,sizeof vis);
    memset(col,0,sizeof col);
    check=0;
    ans=1;
    tmp=1;
    for (int i=1;i<N;i++)
    {
        adj[i].clear();
    }
}

int main()
{
    ANS[0]=1;
    for (int i=1;i<N;i++)
    {
        ANS[i]=2*ANS[i-1];
        ANS[i]%=mod;
        ANS[i]%=mod;
    }
    scanf("%lld",&t);
    while(t--)
    {
        int comp=0;
        init();
        scanf("%lld%lld",&n,&m);
        for (int i=0; i<m; i++)
        {
            scanf("%lld%lld",&u,&v);
            adj[u].pb(v);
            adj[v].pb(u);
        }
        ll emp=0;
        for (int i=1;i<=n;i++)
        {
            if (!vis[i])
            {
                comp++;
                tmp=1;
                col[i]=1;
                DFS(i);
                emp+=2*tmp;
                emp%=mod;
                emp%=mod;
            }
        }
        ans=emp;
        tmp=1;
        memset(col,0,sizeof col);
        memset(vis,0,sizeof vis);
        emp=1;
        for (int i=1;i<=n;i++)
        {
            if (!vis[i])
            {
                tmp=1;
                col[i]=2;
                DFS(i);
                emp*=tmp;
                emp%=mod;
                emp%=mod;
            }
        }
        if (comp>1)
        ans*=emp;
        else ans+=emp;
        ans%=mod;
        ans%=mod;
        if (check)ans=0;
        printf("%lld\n",ans);
    }
    return 0;
}
/**
1
13 12
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
7 12
7 13
**/


#include <bits/stdc++.h>

#define NM 300002
#define MOD 998244353
#define ll long long

using namespace std;

vector <int> gr[NM];

int t;

int n, m;

bool c[NM], v[NM];
bool ok;
int bl;
int nr;

void dfs(int &u, bool &color)
{
    nr++;
    c[u] = color;
    v[u] = 1;
    if(color)
        bl++;
    color = !color;
    for(auto e : gr[u])
        if(v[e])
        {
            if(c[e] == c[u])
            {
                ok = 0;
                return;
            }
        }
        else
        {
            dfs(e, color);
            if(!ok)
                return;
        }
    color = !color;
}

int pwr(int a, int b)
{
    if(b == 0)
        return 1;
    int p = pwr(a, b / 2);
    if(b & 1)
        return 1ll * p * p % MOD * a % MOD;
    return 1ll * p * p % MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> t;
    while(t--)
    {
        cin >> n >> m;
        for(int i = 1; i <= n; i++)
            gr[i].clear();
        for(int i = 1; i <= m; i++)
        {
            int u, v;
            cin >> u >> v;
            gr[u].push_back(v);
            gr[v].push_back(u);
        }
        memset(v, 0, sizeof(v));
        memset(c, 0, sizeof(c));
        ll ans = 1;
        for(int i = 1; i <= n; i++)
            if(!v[i])
            {
                ok = 1;
                bl = 0;
                nr = 0;
                int us = i;
                bool cs = 0;
                dfs(us, cs);
                if(ok)
                    ans = (ans * (1ll * pwr(2, bl) + pwr(2, nr - bl))) % MOD;
                else
                {
                    ans = 0;
                    break;
                }
            }
        cout << ans << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>

#define NM 300002
#define MOD 998244353
#define ll long long

using namespace std;

vector <int> gr[NM];

int t;

int n, m;

bool c[NM], v[NM];
bool ok;
int bl;
int nr;

void dfs(int &u, bool &color)
{
    nr++;
    c[u] = color;
    v[u] = 1;
    if(color)
        bl++;
    color = !color;
    for(auto e : gr[u])
        if(v[e])
        {
            if(c[e] == c[u])
                ok = 0;
        }
        else
            dfs(e, color);
    color = !color;
}

ll pwr(int a, int b)
{
    if(b == 0)
        return 1;
    ll p = pwr(a, b / 2);
    if(b & 1)
        return 1ll * p * p % MOD * a % MOD;
    return 1ll * p * p % MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> t;
    while(t--)
    {
        cin >> n >> m;
        for(int i = 1; i <= n; i++)
            gr[i].clear();
        for(int i = 1; i <= m; i++)
        {
            int u, v;
            cin >> u >> v;
            gr[u].push_back(v);
            gr[v].push_back(u);
        }
        memset(v, 0, sizeof(v));
        memset(c, 0, sizeof(c));
        ll ans = 1;
        for(int i = 1; i <= n; i++)
            if(!v[i])
            {
                ok = 1;
                bl = 0;
                nr = 0;
                int us = i;
                bool cs = 0;
                dfs(us, cs);
                if(ok)
                    ans = (ans * (1ll * pwr(2, bl) + pwr(2, nr - bl)) % MOD) % MOD;
                else
                    ans = 0;
            }
        cout << ans << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>

#define NM 300002
#define MOD 998244353
#define ll long long

using namespace std;

vector <int> gr[NM];

int t;

int n, m;

bool c[NM], v[NM];
bool ok;
int bl;

void dfs(int u, bool color)
{
    c[u] = color;
    v[u] = 1;
    if(color)
        bl++;
    for(auto e : gr[u])
        if(v[e])
        {
            if(c[e] == c[u])
            {
                ok = 0;
                return;
            }
        }
        else
        {
            dfs(e, !color);
            if(!ok)
                return;
        }
}

ll pwr(int a, int b)
{
    if(b == 0)
        return 1;
    ll p = pwr(a, b / 2);
    if(b & 1)
        return 1ll * p * p % MOD * a % MOD;
    return 1ll * p * p % MOD;
}

int main()
{
    cin >> t;
    while(t--)
    {
        cin >> n >> m;
        for(int i = 1; i <= n; i++)
            gr[i].clear();
        for(int i = 1; i <= m; i++)
        {
            int u, v;
            cin >> u >> v;
            gr[u].push_back(v);
            gr[v].push_back(u);
        }
        memset(v, 0, sizeof(v));
        memset(c, 0, sizeof(c));
        ok = 1;
        bl = 0;
        dfs(1, 0);
        if(ok)
            cout << (pwr(2, bl) + pwr(2, n - bl)) % MOD << "\n";
        else
            cout << "0\n";
    }
    return 0;
}


import java.util.*;
public class Fence {
    public static Scanner scan = new Scanner(System.in);
    public static void main(String[] args) {
        int testcases = scan.nextInt();
        for (int i=0; i<testcases; i++) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int c = scan.nextInt();
            int d = Math.max(Math.max(a,b),c);
            if (a+b+c-1>0)System.out.println(a+b+c-1);
            else System.out.println(2*d-a+b+c+1);
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

public class Main {
    static void solve() throws IOException {
int a = nextInt();
 int b = nextInt();
  int c = nextInt();
  int ans12 = Math.min(a , b );
   int ans21 = Math.min( b, c);
   int ans23 = Math.min( ans12 , ans21 );
  int ans1 = Math.max(a , b );
  int ans2 = Math.max( b , c );
  int ans = Math.max(ans1 , ans2 );
  int range = ans - ans23+1;
  int result = (int)(Math.random()*range)+ans23 ;

    }

    static int nextInt() throws IOException{
        return parseInt(scanString());
    }
    static long nextLong() throws IOException
    {
        return parseLong(scanString());
    }
    static String scanString() throws IOException
    {
        while( tok==null || !tok.hasMoreTokens())
        {
            tok = new StringTokenizer( br.readLine());
        }
        return tok.nextToken();

    }
    static BufferedReader br ;
    static PrintWriter out ;
    static StringTokenizer tok ;
    static int test  ;

    public static void main(String[] args) throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter( System.out);
            test = nextInt();
            while( test-- > 0)
            {
                solve();
            }
            br.close();
            out.close();

        }
        catch( Throwable e )
        {
            e.printStackTrace();
            exit(1);
        }
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

public class Main {
    static void solve() throws IOException {
long a = nextLong();
long b = nextLong();
long c = nextLong();
long ans = a+b+c-1;
out.println(ans);

    }

    static int nextInt() throws IOException
    {
   return  parseInt(scanString());
    }
    static long nextLong() throws IOException
    {
        return parseLong(scanString());
    }
    static String scanString() throws IOException
    {
        while( tok==null || !tok.hasMoreTokens())
        {
            tok = new StringTokenizer( br.readLine());
        }
        return tok.nextToken();

    }
    static BufferedReader br ;
    static PrintWriter out ;
    static StringTokenizer tok ;
    static int test  ;

    public static void main(String[] args) throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter( System.out);
            test = nextInt();
            while( test-- > 0)
            {
                solve();
            }
            br.close();
            out.close();

        }
        catch( Throwable e )
        {
            e.printStackTrace();
            exit(1);
        }
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

public class Main {
    static void solve() throws IOException {
int a = nextInt();
 int b = nextInt();
  int c = nextInt();
  int ans12 = Math.min(a , b );
   int ans21 = Math.min( b, c);
   int ans23 = Math.min( ans12 , ans21 );
  int ans1 = Math.max(a , b );
  int ans2 = Math.max( b , c );
  int ans = Math.max(ans1 , ans2 );
  int range = ans - ans23+1;
  int result = (int)(Math.random()*range)+ans23 ;

out.println(result);
    }

    static int nextInt() throws IOException{
        return parseInt(scanString());
    }
    static long nextLong() throws IOException
    {
        return parseLong(scanString());
    }
    static String scanString() throws IOException
    {
        while( tok==null || !tok.hasMoreTokens())
        {
            tok = new StringTokenizer( br.readLine());
        }
        return tok.nextToken();

    }
    static BufferedReader br ;
    static PrintWriter out ;
    static StringTokenizer tok ;
    static int test  ;

    public static void main(String[] args) throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter( System.out);
            test = nextInt();
            while( test-- > 0)
            {
                solve();
            }
            br.close();
            out.close();

        }
        catch( Throwable e )
        {
            e.printStackTrace();
            exit(1);
        }
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

public class Main {
    static void solve() throws IOException {
        int a = nextInt();
        int b = nextInt();
         int c = nextInt();
         int max = a+b+c;

          int min = a ;
          if( min > b )
          {
              min =  b ;
          }
          else if( min > c )
          {
              min = c;

          }
          int range = 2*max-min+1 ;
int ans = (int) (Math.random()*range)+min;
out.println(ans);

    }

    static int nextInt() throws IOException{
        return parseInt(scanString());
    }
    static long nextLong() throws IOException
    {
        return parseLong(scanString());
    }
    static String scanString() throws IOException
    {
        while( tok==null || !tok.hasMoreTokens())
        {
            tok = new StringTokenizer( br.readLine());
        }
        return tok.nextToken();

    }
    static BufferedReader br ;
    static PrintWriter out ;
    static StringTokenizer tok ;
    static int test  ;

    public static void main(String[] args) throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter( System.out);
            test = nextInt();
            while( test-- > 0)
            {
                solve();
            }
            br.close();
            out.close();

        }
        catch( Throwable e )
        {
            e.printStackTrace();
            exit(1);
        }
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

public class Main {
    static void solve() throws IOException {
long a = nextLong();
long b = nextLong();
long c = nextLong();
long ans = a+b+c-1;
out.println(ans);

    }

    static int nextInt()
    {
   return  parseInt(scanString());
    }
    static long nextLong() throws IOException
    {
        return parseLong(scanString());
    }
    static String scanString() throws IOException
    {
        while( tok==null || !tok.hasMoreTokens())
        {
            tok = new StringTokenizer( br.readLine());
        }
        return tok.nextToken();

    }
    static BufferedReader br ;
    static PrintWriter out ;
    static StringTokenizer tok ;
    static int test  ;

    public static void main(String[] args) throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter( System.out);
            test = nextInt();
            while( test-- > 0)
            {
                solve();
            }
            br.close();
            out.close();

        }
        catch( Throwable e )
        {
            e.printStackTrace();
            exit(1);
        }
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

public class Main {
    static void solve() throws IOException {
        int a = nextInt();
        int b = nextInt();
         int c = nextInt();
         int max = a ;
          int min = a ;
         if( max < b )
          {
              max = b ;

          }
          else if( max < c )
          {
              max =c ;
          }
          if( min > b )
          {
              min =  b ;
          }
          else if( min > c )
          {
              min = c;

          }
          int range = max-min+1 ;
int ans = (int) (Math.random()*range)+min;
out.println(ans);

    }

    static int nextInt() throws IOException{
        return parseInt(scanString());
    }
    static long nextLong() throws IOException
    {
        return parseLong(scanString());
    }
    static String scanString() throws IOException
    {
        while( tok==null || !tok.hasMoreTokens())
        {
            tok = new StringTokenizer( br.readLine());
        }
        return tok.nextToken();

    }
    static BufferedReader br ;
    static PrintWriter out ;
    static StringTokenizer tok ;
    static int test  ;

    public static void main(String[] args) throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter( System.out);
            test = nextInt();
            while( test-- > 0)
            {
                solve();
            }
            br.close();
            out.close();

        }
        catch( Throwable e )
        {
            e.printStackTrace();
            exit(1);
        }
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

public class Main {
    static void solve() throws IOException {
        int a = nextInt();
        int b = nextInt();
         int c = nextInt();
         int max = a+b+c;

          int min = a ;
          if( min > b )
          {
              min =  b ;
          }
          else if( min > c )
          {
              min = c;

          }
          int range = max-min+1 ;
int ans = (int) (Math.random()*range)+min;
out.println(ans);

    }

    static int nextInt() throws IOException{
        return parseInt(scanString());
    }
    static long nextLong() throws IOException
    {
        return parseLong(scanString());
    }
    static String scanString() throws IOException
    {
        while( tok==null || !tok.hasMoreTokens())
        {
            tok = new StringTokenizer( br.readLine());
        }
        return tok.nextToken();

    }
    static BufferedReader br ;
    static PrintWriter out ;
    static StringTokenizer tok ;
    static int test  ;

    public static void main(String[] args) throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter( System.out);
            test = nextInt();
            while( test-- > 0)
            {
                solve();
            }
            br.close();
            out.close();

        }
        catch( Throwable e )
        {
            e.printStackTrace();
            exit(1);
        }
    }

}


import java.util.Scanner;
// import java.util.ArrayList;
// import java.util.Arrays;
// import java.util.HashMap;
// import java.util.HashSet;

public class ans1{
    static int mod = (int)10e8;

    public static int lower(int arr[],int key){
        int low = 0;
        int high = arr.length-1;
        while(low < high){
            int mid = low + (high - low)/2;
            if(arr[mid] >= key){
                high = mid;
            }
            else{
                low = mid+1;
            }
        }
        return low;
    }

    public static int upper(int arr[],int key){
        int low = 0;
        int high = arr.length-1;
        while(low < high){
            int mid = low + (high - low+1)/2;
            if(arr[mid] <= key){
                low = mid;
            }
            else{
                high = mid-1;
            }
        }
        return low;
    }

    public static void main(String args[]){
        Scanner scn = new Scanner(System.in);

        int test = scn.nextInt();
        StringBuilder sb = new StringBuilder();
        while(test-- > 0){
            long a = scn.nextLong();
            long b = scn.nextLong();
            long c = scn.nextLong();
            // long ans = 0;

            sb.append(a);
            sb.append("\n");
        }
        System.out.println(sb);
    }
}


import java.util.Scanner;
// import java.util.ArrayList;
// import java.util.Arrays;
// import java.util.HashMap;
// import java.util.HashSet;

public class ans1{
    static int mod = (int)10e8;

    public static int lower(int arr[],int key){
        int low = 0;
        int high = arr.length-1;
        while(low < high){
            int mid = low + (high - low)/2;
            if(arr[mid] >= key){
                high = mid;
            }
            else{
                low = mid+1;
            }
        }
        return low;
    }

    public static int upper(int arr[],int key){
        int low = 0;
        int high = arr.length-1;
        while(low < high){
            int mid = low + (high - low+1)/2;
            if(arr[mid] <= key){
                low = mid;
            }
            else{
                high = mid-1;
            }
        }
        return low;
    }

    public static void main(String args[]){
        Scanner scn = new Scanner(System.in);

        int test = scn.nextInt();
        StringBuilder sb = new StringBuilder();
        while(test-- > 0){
            long a = scn.nextLong();
            long b = scn.nextLong();
            long c = scn.nextLong();
            // long ans = 0;
            long ans = Math.max(a , Math.max(b , c));
            sb.append(ans);
            sb.append("\n");
        }
        System.out.println(sb);
    }
}


import java.util.Scanner;
// import java.util.ArrayList;
// import java.util.Arrays;
// import java.util.HashMap;
// import java.util.HashSet;

public class ans1{
    static int mod = (int)10e8;

    public static int lower(int arr[],int key){
        int low = 0;
        int high = arr.length-1;
        while(low < high){
            int mid = low + (high - low)/2;
            if(arr[mid] >= key){
                high = mid;
            }
            else{
                low = mid+1;
            }
        }
        return low;
    }

    public static int upper(int arr[],int key){
        int low = 0;
        int high = arr.length-1;
        while(low < high){
            int mid = low + (high - low+1)/2;
            if(arr[mid] <= key){
                low = mid;
            }
            else{
                high = mid-1;
            }
        }
        return low;
    }

    public static void main(String args[]){
        Scanner scn = new Scanner(System.in);

        int test = scn.nextInt();
        StringBuilder sb = new StringBuilder();
        while(test-- > 0){
            long a = scn.nextLong();
            long b = scn.nextLong();
            long c = scn.nextLong();
            long ans = 0;

            if(a >= b && a >= c){
                long h = Math.max(b,c) - Math.min(b , c);
                ans = (long)Math.sqrt(Math.pow(h , 2) + Math.pow(a , 2));
            }else if(b > c && b >= a){
                long h = Math.max(a,c) - Math.min(a , c);
                ans = (long)Math.sqrt(Math.pow(h , 2) + Math.pow(c , 2));
            }else if(c >= a && c >= b){
                long h = Math.max(b,a) - Math.min(b , a);
                ans = (long)Math.sqrt(Math.pow(h , 2) + Math.pow(c , 2));
            }
            if(ans == 0) ans++;
            sb.append(ans);
            sb.append("\n");
        }
        System.out.println(sb);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.StringTokenizer;

 public class B {

	public static void main(String[]args) {
		FastReader fs=new FastReader();
		int t=fs.nextInt();
		for(int tt=0;tt<t;tt++) {

		int a=fs.nextInt();
		int b=fs.nextInt();
		int c=fs.nextInt();

			/*
			 * int k=fs.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++)
			 * a[i]=fs.nextInt();
			 */

		System.out.println(solveD(a,b,c));
		//  System.out.println(solve(a,k,n));
		}
		}
	static int solveD(int a,int b,int c) {
		int d=0;
		if(a==b&&b==c)d=a;
		if(a==b)d=c;
		if(b==c)d=a;
		if(a==c)d=b;
		else {
			if(c+a!=b)d=c+a;
			else if(c+b!=a)d=c+b;
			else if(a+b!=c)d=a+b;
		}
			;
		return d;
	}

	static int solveD6(int a[],int x,int p,int k,int n) {
		int res=0;
		Arrays.sort(a);
		if(k<p) {
			if(a[p-1]>x)res=-1;
			else {
				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;

				}
			}
			return res;
		}
		else if(k>p){
			if(a[p-1]<x)res=-1;
			else {
				int i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}
			return res;
		}
		 if(k==p) {

			if(a[p-1]<x) {

				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;
				}

				}
			if(a[p-1]>=x) {

				int	i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}

		}
		 return res;

	}
	static long solve(long a[],int k,int n) {
		long day=0;boolean flag=false;
		a[0]=a[0]-k;
		if(a[0]<0) {
			day=1;
			flag=true;
		}
		else {
		for(int i=1;i<n;i++) {
			a[i]=a[i]+a[i-1]-k;
			if(a[i]<0) {
				day=i+1;
				flag=true;
				return day;
			}
			}
		}
		if(flag==false) {
			 day=n;
			long x=a[n-1];
			day+=x/k+1;

		}
		return day;

	}

	  static int solveD1(int a[],int x,int p,int k,int n) {
			int res=0;
			Arrays.sort(a);
			 if(k==p) {
				if(a[p-1]<x) {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
					}

					}
				else {

					int	i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
					}
				}
				System.out.print(res);
				return res;
			}
			else if(k<p) {
				if(a[p-1]>x)res=-1;
				else {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
						else break;
					}
				}
				return res;

			}
			else  {
				if(a[p-1]<x)res=-1;
				else {

					int i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
						else break;
					}

				}
				return res;
			}

		}

		static void solve32(long a[],int n) {
		Map<Long,Long>hm=new HashMap<>();
		for(int i=0;i<n;i++) {
			long x=highestonebit(a[i]);
			if(!hm.containsKey(x))
				hm.put(x,Long.valueOf(1));
			else
				hm.put(x,hm.get(x)+1);
		}
		long result=0;
		for(long x:hm.values()) {
			if(x>=2)
				result+=x*(x-1)/2;
		}
		System.out.println(result);

	}
	static long highestonebit(long n) {
		if(n==0)return 0;
		else {
			long res=0;
			while(n>0) {
				n/=2;
				res++;
			}
			return res;
		}
	}

	static int solve15(long a[],int n) {
		Set<Long> hs=new HashSet<>();
		hs.add(Long.valueOf(0));
		long sum=0;int count=0;
		for(int i=0;i<n;i++) {
			sum+=a[i];
			if(hs.contains(sum)) {
				count++;
				hs.clear();
				hs.add(Long.valueOf(0));
				sum=a[i];
			}
			hs.add(sum);
		}

		return count;
	}

	public static void solve1(String s) {

		String []ss=s.split("0");
		List<String>l=new ArrayList<>();
		for(String st:ss) {
			if(st!=null||st.length()!=0)
				l.add(st);
		}
		int arr[]=new int[l.size()];

		for(int i=0;i<l.size();i++)
			arr[i]=l.get(i).length();

		Arrays.sort(arr);

		int count=0;
		for(int i=arr.length-1;i>=0;i-=2)
			count+=arr[i];

			System.out.println(count);

	}

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.StringTokenizer;

 public class B {

	public static void main(String[]args) {
		FastReader fs=new FastReader();
		int t=fs.nextInt();
		for(int tt=0;tt<t;tt++) {

		int a=fs.nextInt();
		int b=fs.nextInt();
		int c=fs.nextInt();

			/*
			 * int k=fs.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++)
			 * a[i]=fs.nextInt();
			 */

		System.out.println(solveD(a,b,c));
		//  System.out.println(solve(a,k,n));
		}
		}
	static int solveD(int a,int b,int c) {
		int d=0;
		if(a==b&&b==c)d=a;
		else if(a==b)d=c;
		else if(b==c)d=a;
		else if(a==c)d=b;
		else if(a!=b&&b!=c&&a!=c) {
			d=a;
		}

		return d;
	}

	static int solveD6(int a[],int x,int p,int k,int n) {
		int res=0;
		Arrays.sort(a);
		if(k<p) {
			if(a[p-1]>x)res=-1;
			else {
				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;

				}
			}
			return res;
		}
		else if(k>p){
			if(a[p-1]<x)res=-1;
			else {
				int i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}
			return res;
		}
		 if(k==p) {

			if(a[p-1]<x) {

				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;
				}

				}
			if(a[p-1]>=x) {

				int	i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}

		}
		 return res;

	}
	static long solve(long a[],int k,int n) {
		long day=0;boolean flag=false;
		a[0]=a[0]-k;
		if(a[0]<0) {
			day=1;
			flag=true;
		}
		else {
		for(int i=1;i<n;i++) {
			a[i]=a[i]+a[i-1]-k;
			if(a[i]<0) {
				day=i+1;
				flag=true;
				return day;
			}
			}
		}
		if(flag==false) {
			 day=n;
			long x=a[n-1];
			day+=x/k+1;

		}
		return day;

	}

	  static int solveD1(int a[],int x,int p,int k,int n) {
			int res=0;
			Arrays.sort(a);
			 if(k==p) {
				if(a[p-1]<x) {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
					}

					}
				else {

					int	i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
					}
				}
				System.out.print(res);
				return res;
			}
			else if(k<p) {
				if(a[p-1]>x)res=-1;
				else {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
						else break;
					}
				}
				return res;

			}
			else  {
				if(a[p-1]<x)res=-1;
				else {

					int i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
						else break;
					}

				}
				return res;
			}

		}

		static void solve32(long a[],int n) {
		Map<Long,Long>hm=new HashMap<>();
		for(int i=0;i<n;i++) {
			long x=highestonebit(a[i]);
			if(!hm.containsKey(x))
				hm.put(x,Long.valueOf(1));
			else
				hm.put(x,hm.get(x)+1);
		}
		long result=0;
		for(long x:hm.values()) {
			if(x>=2)
				result+=x*(x-1)/2;
		}
		System.out.println(result);

	}
	static long highestonebit(long n) {
		if(n==0)return 0;
		else {
			long res=0;
			while(n>0) {
				n/=2;
				res++;
			}
			return res;
		}
	}

	static int solve15(long a[],int n) {
		Set<Long> hs=new HashSet<>();
		hs.add(Long.valueOf(0));
		long sum=0;int count=0;
		for(int i=0;i<n;i++) {
			sum+=a[i];
			if(hs.contains(sum)) {
				count++;
				hs.clear();
				hs.add(Long.valueOf(0));
				sum=a[i];
			}
			hs.add(sum);
		}

		return count;
	}

	public static void solve1(String s) {

		String []ss=s.split("0");
		List<String>l=new ArrayList<>();
		for(String st:ss) {
			if(st!=null||st.length()!=0)
				l.add(st);
		}
		int arr[]=new int[l.size()];

		for(int i=0;i<l.size();i++)
			arr[i]=l.get(i).length();

		Arrays.sort(arr);

		int count=0;
		for(int i=arr.length-1;i>=0;i-=2)
			count+=arr[i];

			System.out.println(count);

	}

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.StringTokenizer;

 public class B {

	public static void main(String[]args) {
		FastReader fs=new FastReader();
		int t=fs.nextInt();
		for(int tt=0;tt<t;tt++) {

		int a=fs.nextInt();
		int b=fs.nextInt();
		int c=fs.nextInt();

			/*
			 * int k=fs.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++)
			 * a[i]=fs.nextInt();
			 */

		System.out.println(solveD(a,b,c));
		//  System.out.println(solve(a,k,n));
		}
		}
	static int solveD(int a,int b,int c) {
		int d=0;
		if(a==b&&b==c)d=a;
		if(a==b)d=c;
		if(b==c)d=a;
		if(a==c)d=b;
		else
			d=c+a;
		return d;
	}

	static int solveD6(int a[],int x,int p,int k,int n) {
		int res=0;
		Arrays.sort(a);
		if(k<p) {
			if(a[p-1]>x)res=-1;
			else {
				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;

				}
			}
			return res;
		}
		else if(k>p){
			if(a[p-1]<x)res=-1;
			else {
				int i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}
			return res;
		}
		 if(k==p) {

			if(a[p-1]<x) {

				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;
				}

				}
			if(a[p-1]>=x) {

				int	i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}

		}
		 return res;

	}
	static long solve(long a[],int k,int n) {
		long day=0;boolean flag=false;
		a[0]=a[0]-k;
		if(a[0]<0) {
			day=1;
			flag=true;
		}
		else {
		for(int i=1;i<n;i++) {
			a[i]=a[i]+a[i-1]-k;
			if(a[i]<0) {
				day=i+1;
				flag=true;
				return day;
			}
			}
		}
		if(flag==false) {
			 day=n;
			long x=a[n-1];
			day+=x/k+1;

		}
		return day;

	}

	  static int solveD1(int a[],int x,int p,int k,int n) {
			int res=0;
			Arrays.sort(a);
			 if(k==p) {
				if(a[p-1]<x) {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
					}

					}
				else {

					int	i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
					}
				}
				System.out.print(res);
				return res;
			}
			else if(k<p) {
				if(a[p-1]>x)res=-1;
				else {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
						else break;
					}
				}
				return res;

			}
			else  {
				if(a[p-1]<x)res=-1;
				else {

					int i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
						else break;
					}

				}
				return res;
			}

		}

		static void solve32(long a[],int n) {
		Map<Long,Long>hm=new HashMap<>();
		for(int i=0;i<n;i++) {
			long x=highestonebit(a[i]);
			if(!hm.containsKey(x))
				hm.put(x,Long.valueOf(1));
			else
				hm.put(x,hm.get(x)+1);
		}
		long result=0;
		for(long x:hm.values()) {
			if(x>=2)
				result+=x*(x-1)/2;
		}
		System.out.println(result);

	}
	static long highestonebit(long n) {
		if(n==0)return 0;
		else {
			long res=0;
			while(n>0) {
				n/=2;
				res++;
			}
			return res;
		}
	}

	static int solve15(long a[],int n) {
		Set<Long> hs=new HashSet<>();
		hs.add(Long.valueOf(0));
		long sum=0;int count=0;
		for(int i=0;i<n;i++) {
			sum+=a[i];
			if(hs.contains(sum)) {
				count++;
				hs.clear();
				hs.add(Long.valueOf(0));
				sum=a[i];
			}
			hs.add(sum);
		}

		return count;
	}

	public static void solve1(String s) {

		String []ss=s.split("0");
		List<String>l=new ArrayList<>();
		for(String st:ss) {
			if(st!=null||st.length()!=0)
				l.add(st);
		}
		int arr[]=new int[l.size()];

		for(int i=0;i<l.size();i++)
			arr[i]=l.get(i).length();

		Arrays.sort(arr);

		int count=0;
		for(int i=arr.length-1;i>=0;i-=2)
			count+=arr[i];

			System.out.println(count);

	}

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.StringTokenizer;

 public class B {

	public static void main(String[]args) {
		FastReader fs=new FastReader();
		int t=fs.nextInt();
		for(int tt=0;tt<t;tt++) {

		int a=fs.nextInt();
		int b=fs.nextInt();
		int c=fs.nextInt();

			/*
			 * int k=fs.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++)
			 * a[i]=fs.nextInt();
			 */

		System.out.println(solveD(a,b,c));
		//  System.out.println(solve(a,k,n));
		}
		}
	static int solveD(int a,int b,int c) {
		int d=0;
		if(a==b&&b==c)d=a;
		else if(a==b)d=c;
		else if(b==c)d=a;
		else if(a==c)d=b;
		else {
			if(c+a!=b)d=c+a;
			else if(c+b!=a)d=c+b;
			else if(a+b!=c)d=a+b;
		}
			;
		return d;
	}

	static int solveD6(int a[],int x,int p,int k,int n) {
		int res=0;
		Arrays.sort(a);
		if(k<p) {
			if(a[p-1]>x)res=-1;
			else {
				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;

				}
			}
			return res;
		}
		else if(k>p){
			if(a[p-1]<x)res=-1;
			else {
				int i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}
			return res;
		}
		 if(k==p) {

			if(a[p-1]<x) {

				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;
				}

				}
			if(a[p-1]>=x) {

				int	i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}

		}
		 return res;

	}
	static long solve(long a[],int k,int n) {
		long day=0;boolean flag=false;
		a[0]=a[0]-k;
		if(a[0]<0) {
			day=1;
			flag=true;
		}
		else {
		for(int i=1;i<n;i++) {
			a[i]=a[i]+a[i-1]-k;
			if(a[i]<0) {
				day=i+1;
				flag=true;
				return day;
			}
			}
		}
		if(flag==false) {
			 day=n;
			long x=a[n-1];
			day+=x/k+1;

		}
		return day;

	}

	  static int solveD1(int a[],int x,int p,int k,int n) {
			int res=0;
			Arrays.sort(a);
			 if(k==p) {
				if(a[p-1]<x) {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
					}

					}
				else {

					int	i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
					}
				}
				System.out.print(res);
				return res;
			}
			else if(k<p) {
				if(a[p-1]>x)res=-1;
				else {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
						else break;
					}
				}
				return res;

			}
			else  {
				if(a[p-1]<x)res=-1;
				else {

					int i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
						else break;
					}

				}
				return res;
			}

		}

		static void solve32(long a[],int n) {
		Map<Long,Long>hm=new HashMap<>();
		for(int i=0;i<n;i++) {
			long x=highestonebit(a[i]);
			if(!hm.containsKey(x))
				hm.put(x,Long.valueOf(1));
			else
				hm.put(x,hm.get(x)+1);
		}
		long result=0;
		for(long x:hm.values()) {
			if(x>=2)
				result+=x*(x-1)/2;
		}
		System.out.println(result);

	}
	static long highestonebit(long n) {
		if(n==0)return 0;
		else {
			long res=0;
			while(n>0) {
				n/=2;
				res++;
			}
			return res;
		}
	}

	static int solve15(long a[],int n) {
		Set<Long> hs=new HashSet<>();
		hs.add(Long.valueOf(0));
		long sum=0;int count=0;
		for(int i=0;i<n;i++) {
			sum+=a[i];
			if(hs.contains(sum)) {
				count++;
				hs.clear();
				hs.add(Long.valueOf(0));
				sum=a[i];
			}
			hs.add(sum);
		}

		return count;
	}

	public static void solve1(String s) {

		String []ss=s.split("0");
		List<String>l=new ArrayList<>();
		for(String st:ss) {
			if(st!=null||st.length()!=0)
				l.add(st);
		}
		int arr[]=new int[l.size()];

		for(int i=0;i<l.size();i++)
			arr[i]=l.get(i).length();

		Arrays.sort(arr);

		int count=0;
		for(int i=arr.length-1;i>=0;i-=2)
			count+=arr[i];

			System.out.println(count);

	}

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.StringTokenizer;

 public class B {

	public static void main(String[]args) {
		FastReader fs=new FastReader();
		int t=fs.nextInt();
		for(int tt=0;tt<t;tt++) {

		int a=fs.nextInt();
		int b=fs.nextInt();
		int c=fs.nextInt();

			/*
			 * int k=fs.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++)
			 * a[i]=fs.nextInt();
			 */

		System.out.println(solveD(a,b,c));
		//  System.out.println(solve(a,k,n));
		}
		}
	static int solveD(int a,int b,int c) {
		int d=0;
		if(a==b&&b==c)d=a;
		else if(a==b)d=c;
		else if(b==c)d=a;
		else if(a==c)d=b;
		else {
			d=a;
		}

		return d;
	}

	static int solveD6(int a[],int x,int p,int k,int n) {
		int res=0;
		Arrays.sort(a);
		if(k<p) {
			if(a[p-1]>x)res=-1;
			else {
				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;

				}
			}
			return res;
		}
		else if(k>p){
			if(a[p-1]<x)res=-1;
			else {
				int i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}
			return res;
		}
		 if(k==p) {

			if(a[p-1]<x) {

				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;
				}

				}
			if(a[p-1]>=x) {

				int	i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}

		}
		 return res;

	}
	static long solve(long a[],int k,int n) {
		long day=0;boolean flag=false;
		a[0]=a[0]-k;
		if(a[0]<0) {
			day=1;
			flag=true;
		}
		else {
		for(int i=1;i<n;i++) {
			a[i]=a[i]+a[i-1]-k;
			if(a[i]<0) {
				day=i+1;
				flag=true;
				return day;
			}
			}
		}
		if(flag==false) {
			 day=n;
			long x=a[n-1];
			day+=x/k+1;

		}
		return day;

	}

	  static int solveD1(int a[],int x,int p,int k,int n) {
			int res=0;
			Arrays.sort(a);
			 if(k==p) {
				if(a[p-1]<x) {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
					}

					}
				else {

					int	i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
					}
				}
				System.out.print(res);
				return res;
			}
			else if(k<p) {
				if(a[p-1]>x)res=-1;
				else {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
						else break;
					}
				}
				return res;

			}
			else  {
				if(a[p-1]<x)res=-1;
				else {

					int i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
						else break;
					}

				}
				return res;
			}

		}

		static void solve32(long a[],int n) {
		Map<Long,Long>hm=new HashMap<>();
		for(int i=0;i<n;i++) {
			long x=highestonebit(a[i]);
			if(!hm.containsKey(x))
				hm.put(x,Long.valueOf(1));
			else
				hm.put(x,hm.get(x)+1);
		}
		long result=0;
		for(long x:hm.values()) {
			if(x>=2)
				result+=x*(x-1)/2;
		}
		System.out.println(result);

	}
	static long highestonebit(long n) {
		if(n==0)return 0;
		else {
			long res=0;
			while(n>0) {
				n/=2;
				res++;
			}
			return res;
		}
	}

	static int solve15(long a[],int n) {
		Set<Long> hs=new HashSet<>();
		hs.add(Long.valueOf(0));
		long sum=0;int count=0;
		for(int i=0;i<n;i++) {
			sum+=a[i];
			if(hs.contains(sum)) {
				count++;
				hs.clear();
				hs.add(Long.valueOf(0));
				sum=a[i];
			}
			hs.add(sum);
		}

		return count;
	}

	public static void solve1(String s) {

		String []ss=s.split("0");
		List<String>l=new ArrayList<>();
		for(String st:ss) {
			if(st!=null||st.length()!=0)
				l.add(st);
		}
		int arr[]=new int[l.size()];

		for(int i=0;i<l.size();i++)
			arr[i]=l.get(i).length();

		Arrays.sort(arr);

		int count=0;
		for(int i=arr.length-1;i>=0;i-=2)
			count+=arr[i];

			System.out.println(count);

	}

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.StringTokenizer;

 public class B {

	public static void main(String[]args) {
		FastReader fs=new FastReader();
		int t=fs.nextInt();
		for(int tt=0;tt<t;tt++) {

	    long a=fs.nextLong();
		long b=fs.nextLong();
		long c=fs.nextLong();

			/*
			 * int k=fs.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++)
			 * a[i]=fs.nextInt();
			 */

		System.out.println(solveD(a,b,c));
		//  System.out.println(solve(a,k,n));
		}
		}
	static long solveD(long a,long b,long c) {
		long d=0;
		if(a==b&&b==c)d=a;
		else if(a==b&&b!=c)d=c;
		else if(b==c&&c!=a)d=a;
		else if(a==c&&c!=b)d=b;
		else if(a!=b&&b!=c&&a!=c) {
			d=a;
		}

		return d;
	}

	static int solveD6(int a[],int x,int p,int k,int n) {
		int res=0;
		Arrays.sort(a);
		if(k<p) {
			if(a[p-1]>x)res=-1;
			else {
				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;

				}
			}
			return res;
		}
		else if(k>p){
			if(a[p-1]<x)res=-1;
			else {
				int i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}
			return res;
		}
		 if(k==p) {

			if(a[p-1]<x) {

				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;
				}

				}
			if(a[p-1]>=x) {

				int	i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}

		}
		 return res;

	}
	static long solve(long a[],int k,int n) {
		long day=0;boolean flag=false;
		a[0]=a[0]-k;
		if(a[0]<0) {
			day=1;
			flag=true;
		}
		else {
		for(int i=1;i<n;i++) {
			a[i]=a[i]+a[i-1]-k;
			if(a[i]<0) {
				day=i+1;
				flag=true;
				return day;
			}
			}
		}
		if(flag==false) {
			 day=n;
			long x=a[n-1];
			day+=x/k+1;

		}
		return day;

	}

	  static int solveD1(int a[],int x,int p,int k,int n) {
			int res=0;
			Arrays.sort(a);
			 if(k==p) {
				if(a[p-1]<x) {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
					}

					}
				else {

					int	i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
					}
				}
				System.out.print(res);
				return res;
			}
			else if(k<p) {
				if(a[p-1]>x)res=-1;
				else {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
						else break;
					}
				}
				return res;

			}
			else  {
				if(a[p-1]<x)res=-1;
				else {

					int i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
						else break;
					}

				}
				return res;
			}

		}

		static void solve32(long a[],int n) {
		Map<Long,Long>hm=new HashMap<>();
		for(int i=0;i<n;i++) {
			long x=highestonebit(a[i]);
			if(!hm.containsKey(x))
				hm.put(x,Long.valueOf(1));
			else
				hm.put(x,hm.get(x)+1);
		}
		long result=0;
		for(long x:hm.values()) {
			if(x>=2)
				result+=x*(x-1)/2;
		}
		System.out.println(result);

	}
	static long highestonebit(long n) {
		if(n==0)return 0;
		else {
			long res=0;
			while(n>0) {
				n/=2;
				res++;
			}
			return res;
		}
	}

	static int solve15(long a[],int n) {
		Set<Long> hs=new HashSet<>();
		hs.add(Long.valueOf(0));
		long sum=0;int count=0;
		for(int i=0;i<n;i++) {
			sum+=a[i];
			if(hs.contains(sum)) {
				count++;
				hs.clear();
				hs.add(Long.valueOf(0));
				sum=a[i];
			}
			hs.add(sum);
		}

		return count;
	}

	public static void solve1(String s) {

		String []ss=s.split("0");
		List<String>l=new ArrayList<>();
		for(String st:ss) {
			if(st!=null||st.length()!=0)
				l.add(st);
		}
		int arr[]=new int[l.size()];

		for(int i=0;i<l.size();i++)
			arr[i]=l.get(i).length();

		Arrays.sort(arr);

		int count=0;
		for(int i=arr.length-1;i>=0;i-=2)
			count+=arr[i];

			System.out.println(count);

	}

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.StringTokenizer;

 public class B {

	public static void main(String[]args) {
		FastReader fs=new FastReader();
		int t=fs.nextInt();
		for(int tt=0;tt<t;tt++) {

	    long a=fs.nextLong();
		long b=fs.nextLong();
		long c=fs.nextLong();

			/*
			 * int k=fs.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++)
			 * a[i]=fs.nextInt();
			 */

		System.out.println(solveD(a,b,c));
		//  System.out.println(solve(a,k,n));
		}
		}
	static long solveD(long a,long b,long c) {

		return a+b+c-1;
	}

	static int solveD6(int a[],int x,int p,int k,int n) {
		int res=0;
		Arrays.sort(a);
		if(k<p) {
			if(a[p-1]>x)res=-1;
			else {
				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;

				}
			}
			return res;
		}
		else if(k>p){
			if(a[p-1]<x)res=-1;
			else {
				int i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}
			return res;
		}
		 if(k==p) {

			if(a[p-1]<x) {

				int i=p-1;
				while(i<n) {
					if(a[i]<x) {
						res++;
						i++;
					}
					else break;
				}

				}
			if(a[p-1]>=x) {

				int	i=p-1;
				while(i>=0) {
					if(a[i]>x) {
						res++;
						i--;
					}
					else break;
				}
			}

		}
		 return res;

	}
	static long solve(long a[],int k,int n) {
		long day=0;boolean flag=false;
		a[0]=a[0]-k;
		if(a[0]<0) {
			day=1;
			flag=true;
		}
		else {
		for(int i=1;i<n;i++) {
			a[i]=a[i]+a[i-1]-k;
			if(a[i]<0) {
				day=i+1;
				flag=true;
				return day;
			}
			}
		}
		if(flag==false) {
			 day=n;
			long x=a[n-1];
			day+=x/k+1;

		}
		return day;

	}

	  static int solveD1(int a[],int x,int p,int k,int n) {
			int res=0;
			Arrays.sort(a);
			 if(k==p) {
				if(a[p-1]<x) {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
					}

					}
				else {

					int	i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
					}
				}
				System.out.print(res);
				return res;
			}
			else if(k<p) {
				if(a[p-1]>x)res=-1;
				else {

					int i=p-1;
					while(i<n) {
						if(a[i]<x) {
							res++;
							i++;
						}
						else break;
					}
				}
				return res;

			}
			else  {
				if(a[p-1]<x)res=-1;
				else {

					int i=p-1;
					while(i>=0) {
						if(a[i]>x) {
							res++;
							i--;
						}
						else break;
					}

				}
				return res;
			}

		}

		static void solve32(long a[],int n) {
		Map<Long,Long>hm=new HashMap<>();
		for(int i=0;i<n;i++) {
			long x=highestonebit(a[i]);
			if(!hm.containsKey(x))
				hm.put(x,Long.valueOf(1));
			else
				hm.put(x,hm.get(x)+1);
		}
		long result=0;
		for(long x:hm.values()) {
			if(x>=2)
				result+=x*(x-1)/2;
		}
		System.out.println(result);

	}
	static long highestonebit(long n) {
		if(n==0)return 0;
		else {
			long res=0;
			while(n>0) {
				n/=2;
				res++;
			}
			return res;
		}
	}

	static int solve15(long a[],int n) {
		Set<Long> hs=new HashSet<>();
		hs.add(Long.valueOf(0));
		long sum=0;int count=0;
		for(int i=0;i<n;i++) {
			sum+=a[i];
			if(hs.contains(sum)) {
				count++;
				hs.clear();
				hs.add(Long.valueOf(0));
				sum=a[i];
			}
			hs.add(sum);
		}

		return count;
	}

	public static void solve1(String s) {

		String []ss=s.split("0");
		List<String>l=new ArrayList<>();
		for(String st:ss) {
			if(st!=null||st.length()!=0)
				l.add(st);
		}
		int arr[]=new int[l.size()];

		for(int i=0;i<l.size();i++)
			arr[i]=l.get(i).length();

		Arrays.sort(arr);

		int count=0;
		for(int i=arr.length-1;i>=0;i-=2)
			count+=arr[i];

			System.out.println(count);

	}

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(final String[] args) throws IOException {
        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(reader.readLine().trim());
        while (t-- > 0) {
            int[] arr = new int[3];
            for (int i = 0; i < 3; i++) {
                arr[i] = Integer.parseInt(reader.readLine().trim());
            }
            Arrays.sort(arr);
            long d = arr[0] + arr[1] - 1;
            System.out.println(d);
        }
        reader.close();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class CSS2 {

    public static void main(final String[] args) throws IOException {
        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(reader.readLine().trim());
        while (t-- > 0) {
            int[] arr = new int[3];
            String[] s = reader.readLine().trim().split(" ");
            for (int i = 0; i < 3; i++) {
                arr[i] = Integer.parseInt(s[i]);
            }
            Arrays.sort(arr);
            long d = arr[0] + arr[1] - 1;
            System.out.println(d);
        }
        reader.close();
    }
}