#include <bits/stdc++.h>
using namespace std;
long long int min(long long int a, long long int b) {
  if (a > b) return b;
  return a;
}
long long int max(long long int a, long long int b) {
  if (a < b) return b;
  return a;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int log(long long int n) {
  long long int i = 0;
  while (n != 1) {
    n = n / 2;
    i++;
  }
  return i;
}
long long int mod = 998244353;
long long int pow2(long long int n) {
  long long int ans = 1;
  while (n--) {
    ans = (ans * 2) % mod;
  }
  return ans;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    vector<vector<long long int> > vec(n + 1);
    long long int vis[n + 1];
    long long int col[n + 1];
    for (long long int i = 0; i <= n; ++i) vis[i] = 0;
    for (long long int i = 0; i <= n; ++i) col[i] = -1;
    for (long long int i = 1; i <= m; ++i) {
      long long int a, b;
      cin >> a >> b;
      vec[a].push_back(b);
      vec[b].push_back(a);
    }
    long long int ans = 1;
    long long int isBarp = 1;
    for (long long int i = 1; i <= n; ++i) {
      if (vis[i] == 0) {
        long long int size = 1;
        long long int tsize = 1;
        col[i] = 1;
        queue<long long int> q;
        q.push(i);
        while (q.size() != 0) {
          long long int f = q.front();
          vis[f] = 1;
          q.pop();
          for (auto j : vec[f]) {
            if (col[j] == -1) {
              col[j] = 1 - col[f];
              q.push(j);
              size++;
              if (col[j] == 1) tsize++;
            } else if (col[j] == col[f]) {
              isBarp = 0;
            }
          }
        }
        ans = (ans * (pow2(tsize) + pow2(size - tsize))) % mod;
      }
    }
    if (isBarp == 0) {
      cout << 0 << '\n';
    } else
      cout << ans << '\n';
  }
}
