import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 998244353;

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}

void solve() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto G = new int[][](N);
    foreach (_; 0..M) {
        s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1]-1;
        G[s[1]-1] ~= s[0]-1;
    }

    long ans = 1;
    auto cnt = new long[](2);
    auto C = new int[](N);
    fill(C, -1);

    bool dfs(int n, int c) {
        if (C[n] != -1)
            return C[n] == c;
        C[n] = c;
        cnt[c] += 1;
        foreach (m; G[n]) {
            if (C[m] != -1) {
                if (C[m] == (c^1))
                    continue;
                else
                    return false;
            }
            if (!dfs(m, c^1))
                return false;
        }
        return true;
    }

    foreach (i; 0..N) {
        if (C[i] != -1) continue;
        cnt[0] = cnt[1] = 0;
        if (dfs(i, 0)) {
            long tmp = powmod(2, cnt[0], MOD) + powmod(2, cnt[1], MOD);
            tmp %= MOD;
            ans = ans * tmp % MOD;
        } else {
            writeln(0);
            return;
        }
    }

    ans.writeln;
}

void main() {
    auto Q = readln.chomp.to!int;
    while (Q--) solve;
}
