#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int mod = 1e9 + 7;
inline void Inc(int &x, int y) { x += y, x -= x >= mod ? mod : 0; }
struct edge {
  int to, next, w;
} e[N * 2];
int head[N], ecnt = 1, ind[N];
inline int rev(int x) { return (x & 1) << 1 | (x >> 1); }
inline void adde(int from, int to, int w) {
  ind[from]++, ind[to]++;
  e[++ecnt] = (edge){to, head[from], w}, head[from] = ecnt;
  e[++ecnt] = (edge){from, head[to], rev(w)}, head[to] = ecnt;
}
vector<int> p;
int vis[N], type[N];
void dfs(int u, int f) {
  vis[u] = 1, type[u] = -1, p.push_back(u);
  for (int i = head[u]; i; i = e[i].next)
    if ((i ^ 1) != f) {
      type[u] = e[i].w;
      if (!vis[e[i].to]) dfs(e[i].to, i);
      if (!f) return;
    }
}
int self[N], dp[N][2][2];
int main() {
  int n, m, base = 0;
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= m; i++) {
    int op, a, b;
    scanf("%d%d", &op, &a);
    if (op == 1)
      self[abs(a)] ^= 1 << (a < 0);
    else {
      scanf("%d", &b);
      int A = abs(a), B = abs(b), type = 0;
      if (a < 0) type ^= 1;
      if (b < 0) type ^= 2;
      if (A != B)
        adde(A, B, type);
      else {
        if (a == b)
          self[abs(a)] ^= 1 << (a < 0);
        else
          base ^= 1;
      }
    }
  }
  auto calc = [](int A, int B, int w) {
    if (w == -1) return 0;
    if (w & 1) A ^= 1;
    if (w & 2) B ^= 1;
    return A | B;
  };
  auto wkr = [](int A, int self) {
    if (self == 0) return 0;
    if (self == 3) return 1;
    return self == 1 ? A : !A;
  };
  auto DP = [&](int n, int from = 1) {
    for (int i = from; i <= n; i++)
      for (int a = 0; a <= 1; a++)
        for (int b = 0; b <= 1; b++)
          if (dp[i - 1][a][b])
            for (int v = 0; v <= 1; v++)
              Inc(dp[i][v][b ^ calc(a, v, i == 1 ? -1 : type[p[i - 2]]) ^
                           wkr(v, self[p[i - 1]])],
                  dp[i - 1][a][b]);
  };
  int res[2] = {1};
  for (int i = 1; i <= n; i++)
    if (ind[i] <= 1 && !vis[i]) {
      p.clear(), dfs(i, 0);
      int t = p.size();
      for (int j = 0; j <= t; j++) memset(dp[j], 0, sizeof(dp[j]));
      dp[0][0][0] = 1, DP(t);
      static int tmp[2];
      tmp[0] = res[0], tmp[1] = res[1], res[0] = res[1] = 0;
      for (int a = 0; a <= 1; a++)
        for (int b = 0; b <= 1; b++)
          for (int c = 0; c <= 1; c++)
            res[b ^ c] = (res[b ^ c] + (long long)dp[t][a][b] * tmp[c]) % mod;
    }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      p.clear(), dfs(i, 0);
      int t = p.size();
      static int nw[2];
      memset(nw, 0, sizeof(nw));
      for (int j = 0; j <= t; j++) memset(dp[j], 0, sizeof(dp[j]));
      dp[1][0][wkr(0, self[p[0]])] = 1, DP(t, 2);
      for (int a = 0; a <= 1; a++)
        for (int b = 0; b <= 1; b++)
          Inc(nw[b ^ calc(a, 0, type[p[t - 1]])], dp[t][a][b]);
      for (int j = 0; j <= t; j++) memset(dp[j], 0, sizeof(dp[j]));
      dp[1][1][wkr(1, self[p[0]])] = 1, DP(t, 2);
      for (int a = 0; a <= 1; a++)
        for (int b = 0; b <= 1; b++)
          Inc(nw[b ^ calc(a, 1, type[p[t - 1]])], dp[t][a][b]);
      static int tmp[2];
      tmp[0] = res[0], tmp[1] = res[1], res[0] = res[1] = 0;
      for (int a = 0; a <= 1; a++)
        for (int b = 0; b <= 1; b++)
          res[a ^ b] = (res[a ^ b] + (long long)nw[a] * tmp[b]) % mod;
    }
  printf("%d\n", res[1 ^ base]);
}
