#include <bits/stdc++.h>
const int MOD = 998244353;
using namespace std;
bool sortcol(const vector<int>& v1, const vector<int>& v2) {
  return v1[1] < v2[1];
}
long long int power(long long int a, long long int n) {
  long long int res = 1;
  while (n) {
    if (n % 2) {
      res = (res * a) % MOD;
    }
    n >>= 1;
    a = (a * a) % MOD;
  }
  return res;
}
long long int ncr(long long int n, long long int r) {
  if (n == 1 || r == 0) return 1;
  if (r > n / 2) r = n - r;
  long long int ans = 1;
  for (long long int i = 1; i <= r; i++) {
    ans = ((ans * n) / i);
    n--;
  }
  return ans;
}
long long int ncrsum(long long int n, long long int r, long long int mod) {
  if (n == 1 || r == 0) return 1;
}
const int maxn = 4e5 + 100;
vector<int> v[maxn];
long long int dis[maxn] = {0};
long long int vis[maxn] = {0};
long long int col[maxn] = {0};
long long int C[2] = {0};
long long int dfs(long long int node, long long int c) {
  vis[node] = 1;
  C[c]++;
  col[node] = c;
  for (auto child : v[node]) {
    if (vis[child] == 0) {
      long long int code = dfs(child, c ^ 1);
      if (code == -1) return -1;
    } else {
      if (col[node] == col[child]) return -1;
    }
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, i1, i2, k, m, j, j1, a1, i31, i3, j2, i5, i4, i6, i7, i;
    long long int x, y, z;
    long long int total = 0, cnt = 0;
    long long int flag = 0;
    y = 0;
    long long int res, res1, ans, res2, q;
    ans = 0;
    res1 = 0, res = 1;
    long long int s1, s2, s3;
    s2 = 0;
    long long int sum = 0;
    s1 = 0;
    long long int k1, k2, k3;
    long long int d;
    string s;
    cin >> n >> m;
    for (i = 1; i <= n; i++) {
      v[i].clear();
      vis[i] = 0;
      col[i] = 0;
    }
    for (i = 1; i <= m; i++) {
      long long int x1, x2;
      cin >> x1 >> x2;
      v[x1].push_back(x2);
      v[x2].push_back(x1);
    }
    bool f1 = true;
    for (i = 1; i <= n; i++) {
      if (vis[i] == 0) {
        C[1] = C[0] = 0;
        x = dfs(i, 0);
        if (x == -1) {
          f1 = false;
          break;
        }
        res = (res * (power(2, C[0]) + power(2, C[1]))) % MOD;
      }
    }
    if (f1 == false)
      cout << 0 << "\n";
    else
      cout << res << "\n";
  }
}
