#include <bits/stdc++.h>
using namespace std;
vector<int> graph[300000 + 10];
int colour[300000 + 10];
int odd = 0, even = 0;
long long modexpo(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res % 998244353 * a % 998244353) % 998244353;
    a = (a % 998244353 * a % 998244353) % 998244353;
    b >>= 1;
  }
  return res;
}
bool isBipartite(int v, int col) {
  colour[v] = 1;
  list<int> q;
  q.push_back(v);
  int u, i;
  while (!q.empty()) {
    u = q.front();
    q.pop_front();
    if (colour[u] == 0)
      even++;
    else
      odd++;
    for (auto x : graph[u]) {
      if (colour[x] == -1) {
        colour[x] = 1 - colour[u];
        q.push_back(x);
      } else if (colour[x] == colour[u])
        return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t, i;
  cin >> t;
  while (t--) {
    long long n, m, u, v;
    cin >> n >> m;
    for (i = 1; i <= n; i++) {
      graph[i].clear();
      colour[i] = -1;
    }
    for (i = 1; i <= m; i++) {
      cin >> u >> v;
      graph[u].push_back(v);
      graph[v].push_back(u);
    }
    long long res = 1;
    for (i = 1; i <= n; i++) {
      if (colour[i] == -1) {
        odd = even = 0;
        if (isBipartite(i, 0)) {
          res = (res % 998244353 *
                 (modexpo(2ll, odd) % 998244353 + modexpo(2ll, even)) %
                 998244353) %
                998244353;
        } else {
          res = 0;
          break;
        }
      }
    }
    cout << res << '\n';
  }
}
