#include <bits/stdc++.h>
using namespace std;
vector<long long> graph[300010];
vector<long long> visited(300010, 0);
vector<long long> level(300010, -1);
vector<long long> parent(300010, -1);
bool bfs(queue<long long> q) {
  while (!q.empty()) {
    long long curr = q.front();
    q.pop();
    for (long long i = 0; i < graph[curr].size(); i++) {
      if (!visited[graph[curr][i]]) {
        parent[graph[curr][i]] = curr;
        level[graph[curr][i]] = level[curr] + 1;
        visited[graph[curr][i]] = 1;
        q.push(graph[curr][i]);
      } else {
        long long now = graph[curr][i];
        long long lv1 = level[now];
        lv1 %= 2;
        long long lv2 = level[curr];
        lv2 %= 2;
        if (lv1 == lv2) {
          return false;
        }
      }
    }
  }
  return true;
}
long long power(long long x, long long y, long long p) {
  long long ans = 1;
  x = x % p;
  if (x == 0) {
    return 0;
  }
  while (y > 0) {
    if (y & 1) {
      ans = (ans * x) % p;
    }
    y = y >> 1;
    x = (x * x) % p;
  }
  ans %= 998244353;
  return ans;
}
vector<long long> visited2(300010, 0);
long long findans(queue<long long> q) {
  long long even = 0, odd = 0;
  while (!q.empty()) {
    long long curr = q.front();
    q.pop();
    if (level[curr] % 2) {
      odd++;
    } else {
      even++;
    }
    for (long long i = 0; i < graph[curr].size(); i++) {
      long long now = graph[curr][i];
      if (!visited2[now]) {
        visited2[now] = 1;
        q.push(now);
      }
    }
  }
  long long ans = power(2, even, 998244353);
  ans += power(2, odd, 998244353);
  ans %= 998244353;
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    for (long long i = 0; i < n; i++) {
      graph[i].clear();
      visited[i] = 0;
      visited2[i] = 0;
      parent[i] = -1;
      level[i] = -1;
    }
    for (long long i = 0; i < m; i++) {
      long long u, v;
      cin >> u >> v;
      u--;
      v--;
      graph[u].push_back(v);
      graph[v].push_back(u);
    }
    bool success = true;
    long long ans = 1;
    for (long long i = 0; i < n; i++) {
      if (!visited[i]) {
        queue<long long> q;
        q.push(i);
        level[i] = 0;
        visited[i] = 1;
        if (bfs(q)) {
          while (!q.empty()) {
            q.pop();
          }
          q.push(i);
          visited2[i] = 1;
          ans *= findans(q);
          ans %= 998244353;
        } else {
          success = false;
        }
      }
    }
    cout << (success ? ans : 0);
    cout << "\n";
  }
}
