#include <bits/stdc++.h>
using namespace std;
vector<int> graph[300001];
bool visited[300001];
int colour[300001];
int colourType[2];
bool isBipartite(int src, int c) {
  visited[src] = true;
  colour[src] = c;
  colourType[c]++;
  for (int i = 0; i < graph[src].size(); i++) {
    int child = graph[src][i];
    if (visited[child] == false) {
      if (isBipartite(child, c ^ 1) == false) {
        return false;
      }
    } else {
      if (colour[src] == colour[child]) {
        return false;
      }
    }
  }
  return true;
}
long long int power(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b % 2 == 0) {
      a = (a * a) % 998244353;
      b = b / 2;
    } else {
      ans = (ans * a) % 998244353;
      b--;
    }
  }
  return ans;
}
int main() {
  int vertices, edges, t;
  cin >> t;
  while (t--) {
    cin >> vertices >> edges;
    int i, j;
    for (i = 0; i <= vertices; i++) {
      graph[i].clear();
      visited[i] = false;
    }
    for (i = 0; i < edges; i++) {
      int u, v;
      cin >> u >> v;
      graph[u].push_back(v);
      graph[v].push_back(u);
    }
    long long int res = 1;
    bool flag = true;
    for (i = 1; i <= vertices; i++) {
      if (visited[i] == false) {
        colourType[0] = colourType[1] = 0;
        bool check = isBipartite(i, 0);
        if (check == false) {
          flag = false;
          break;
        } else {
          res = (res *
                 (power(2, colourType[0]) % 998244353 +
                  power(2, colourType[1]) % 998244353) %
                 998244353) %
                998244353;
        }
      }
    }
    if (flag == false) {
      cout << 0 << "\n";
    } else {
      cout << res << "\n";
    }
  }
  return 0;
}
