#include <bits/stdc++.h>
using namespace std;
long long int Lpow(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b % 2) ans = (ans * a) % 998244353;
    a = (a * a) % 998244353;
    b = b / 2;
  }
  return ans;
}
long long int gcd(long long int a, long long int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
vector<vector<int>> adj(300005);
vector<int> vis;
long long int cnt;
long long int tot;
int fl;
void dfs(long long int node, long long int p) {
  if (p == 1) cnt++;
  tot++;
  if (p == 1)
    vis[node] = 1;
  else
    vis[node] = 2;
  for (auto x : adj[node]) {
    if (vis[x] == 0)
      dfs(x, (p + 1) % 2);
    else if (vis[x] == 1 && p == 1)
      fl = 1;
    else if (vis[x] == 2 && p == 0)
      fl = 1;
  }
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    fl = 0;
    for (int i = 0; i < n + 2; i++) adj[i].clear();
    vis.clear();
    vis.resize(n + 1, 0);
    int a, b;
    for (int i = 0; i < m; i++) {
      cin >> a >> b;
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    long long int ans = 1;
    for (int i = 1; i <= n; i++) {
      if (vis[i] == 0) {
        cnt = 0;
        tot = 0;
        dfs(i, 0);
        if (fl == 1) break;
        ans =
            ans * ((Lpow(2, cnt) + Lpow(2, tot - cnt)) % 998244353) % 998244353;
      }
    }
    if (fl == 1)
      cout << 0 << '\n';
    else {
      cout << ans << '\n';
    }
  }
  return 0;
}
