#include <bits/stdc++.h>
using namespace std;
bool v[120009];
vector<int> g[120009], temp;
int l[120009], r[120009], n, m;
long long ans[2] =
    {
        1,
},
          dp[2][2], cal[2];
int call(int id, int a, int b, int c, int d) {
  if (abs(l[id]) != a) {
    swap(a, c);
    swap(b, d);
  }
  int uu, oo;
  if (l[id] < 0)
    uu = b ^ 1;
  else
    uu = b;
  if (r[id] < 0)
    oo = d ^ 1;
  else
    oo = d;
  return oo | uu;
}
void dfs(int a, int b, int c) {
  v[a] = true;
  temp.push_back(a);
  long long k[2][2];
  memset(k, 0, sizeof(k));
  for (int i = 0; i < 2; i++) {
    if (b == a && i != c) continue;
    for (int j = 0; j < 2; j++) {
      for (int ii = 0; ii < 2; ii++) {
        int ok = 0;
        for (int u = 0; u < g[a].size(); u++) {
          int aa;
          int o = g[a][u];
          int y = abs(l[o]) + abs(r[o]) - a;
          if (v[y]) {
            if (y == b)
              aa = c;
            else if (y == a)
              aa = i;
            else
              aa = ii;
            ok ^= call(o, a, i, y, aa);
          }
        }
        k[j ^ ok][i] = (k[j ^ ok][i] + dp[j][ii]) % 1000000007;
      }
    }
  }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) dp[i][j] = k[i][j];
  for (int i = 0; i < g[a].size(); i++) {
    int ii = g[a][i];
    int aa = abs(l[ii]) + abs(r[ii]) - a;
    if (!v[aa]) dfs(aa, b, c);
  }
}
int main() {
  memset(v, false, sizeof(v));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int u;
    scanf("%d", &u);
    if (u > 1) {
      scanf("%d%d", &l[i], &r[i]);
      if (abs(l[i]) != abs(r[i])) {
        g[abs(l[i])].push_back(i);
        g[abs(r[i])].push_back(i);
      } else
        g[abs(l[i])].push_back(i);
    } else {
      scanf("%d", &l[i]);
      r[i] = l[i];
      g[abs(l[i])].push_back(i);
    }
  }
  long long te[2];
  for (int i = 1; i <= m; i++) {
    memset(te, 0, sizeof(te));
    if (!v[i]) {
      temp.clear();
      for (int j = 0; j < 2; j++) {
        memset(dp, 0, sizeof(dp));
        dp[0][j] = 1;
        for (int p = 0; p < temp.size(); p++) v[temp[p]] = false;
        dfs(i, i, j);
        for (int iii = 0; iii < 2; iii++)
          for (int jjj = 0; jjj < 2; jjj++) te[iii] += dp[iii][jjj];
      }
      te[0] %= 1000000007;
      te[1] %= 1000000007;
      memset(cal, 0, sizeof(cal));
      for (int a = 0; a < 2; a++)
        for (int b = 0; b < 2; b++)
          cal[a ^ b] =
              (cal[a ^ b] + 1LL * ans[a] * te[b] % 1000000007) % 1000000007;
      ans[0] = cal[0];
      ans[1] = cal[1];
    }
  }
  printf("%lld\n", ans[1]);
  return 0;
}
