#include <bits/stdc++.h>
using namespace std;
vector<int> bipa(vector<vector<int>>& adj, vector<int>& color, int n) {
  if (adj[n].size() == 0) {
    color[n] = -1;
    return {0};
  }
  queue<int> q;
  q.push(n);
  int x, count = 0;
  vector<int> v;
  while (!q.empty()) {
    x = q.front();
    q.pop();
    v.push_back(color[x]);
    for (int i = 0; i < adj[x].size(); i++) {
      if (color[adj[x][i]] == -1) {
        color[adj[x][i]] = color[x] ^ 1;
        q.push(adj[x][i]);
      } else if (color[adj[x][i]] == color[x])
        return {};
    }
  }
  return v;
}
long long int power(long long int x, long long int a, long long int mod) {
  if (a == 0) return 1;
  long long int ans = power(x, a / 2, mod);
  ans = (ans * ans) % mod;
  if (a % 2 == 1) ans = (ans * x) % mod;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t, n, m, i, x, y, j;
  long long int ans, odd, sing, mod = 998244353;
  vector<int> v;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    vector<vector<int>> adj(n);
    vector<int> color(n);
    for (i = 0; i < m; i++) {
      cin >> x >> y;
      adj[x - 1].push_back(y - 1);
      adj[y - 1].push_back(x - 1);
    }
    for (i = 0; i < n; i++) color[i] = -1;
    for (i = 0, ans = 1; i < n; i++) {
      if (color[i] == -1) {
        color[i] = 0;
        v = bipa(adj, color, i);
        if (v.size() == 0)
          break;
        else {
          for (j = 0, odd = 0; j < v.size(); j++) {
            if (v[j] == 0) odd++;
          }
          x = power(2, odd, mod);
          y = power(2, v.size() - odd, mod);
          ans = (ans * (x + y)) % mod;
        }
      }
    }
    if (i != n)
      cout << 0 << '\n';
    else {
      cout << ans << '\n';
    }
  }
}
