#include <bits/stdc++.h>
using namespace std;
const int mod = int(1e9) + 7;
long long dp[100500][2][2];
pair<int, int> e[100500];
pair<int, int> d[100500];
int c[100500];
bool visited[100500];
bool vtroka[100500];
inline void rev(int j) {
  swap(d[j].first, d[j].second);
  swap(e[j].first, e[j].second);
}
void dfs(int i) {
  visited[i] = true;
  dp[i][0][0] = dp[i][0][1] = dp[i][1][0] = dp[i][1][1] = 0;
  int curr = d[i].first;
  if (curr == 0) {
    dp[i][1][1] = dp[i][0][0] = 1;
    return;
  }
  int j = c[curr] - i;
  if (j) {
    if (d[j].second != curr) rev(j);
    dfs(j);
    if (e[i].first != e[j].second) {
      swap(dp[j][1][0], dp[j][0][0]);
      swap(dp[j][1][1], dp[j][0][1]);
    }
  } else {
    dp[j][1][0] = dp[j][0][0] = 1;
    dp[j][1][1] = dp[j][0][1] = 0;
  }
  for (int i_put = 0; i_put < 2; i_put++)
    for (int j_put = 0; j_put < 2; j_put++)
      for (int j_res = 0; j_res < 2; j_res++)
        dp[i][i_put][(j_res + max(i_put, j_put)) & 1] += dp[j][j_put][j_res];
  for (int x = 0; x < 2; x++)
    for (int y = 0; y < 2; y++) dp[i][x][y] %= mod;
  if (d[i].second == 0) dp[i][1][0] = dp[i][1][1] = 0;
}
inline long long get(int i, int par) { return dp[i][0][par] + dp[i][1][par]; }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  long long r0 = 1;
  long long r1 = 0;
  for (int i = 1; i <= n; i++) {
    int k, x, y = 0;
    scanf("%d%d", &k, &x);
    if (k == 2) {
      scanf("%d", &y);
    }
    e[i] = make_pair(x, y);
    if (x < 0) x *= -1;
    if (y < 0) y *= -1;
    vtroka[x] = vtroka[y] = true;
    d[i] = make_pair(x, y);
    c[x] += i;
    c[y] += i;
    if (x == y) {
      visited[i] = true;
      if (e[i].first == e[i].second) {
        r0 = r1 = (r0 + r1) % mod;
      } else {
        swap(r0, r1);
        r0 *= 2;
        r1 *= 2;
      }
      continue;
    }
  }
  for (int i = 1; i <= n; i++)
    if (!visited[i] &&
        (d[i].second == 0 || c[d[i].first] == i || c[d[i].second] == i)) {
      visited[i] = true;
      if (c[d[i].first] == i && d[i].second == 0) {
        r0 = r1 = (r0 + r1) % mod;
        continue;
      }
      if (c[d[i].first] == i && c[d[i].second] == i) {
        long long z0 = 1;
        long long z1 = 3;
        long long t0 = r0 * z0 + r1 * z1;
        long long t1 = r1 * z0 + r0 * z1;
        r0 = t0 % mod;
        r1 = t1 % mod;
        continue;
      }
      if (c[d[i].first] == i) rev(i);
      dfs(i);
      long long t0 = r0 * get(i, 0) + r1 * get(i, 1);
      long long t1 = r1 * get(i, 0) + r0 * get(i, 1);
      r0 = t0 % mod;
      r1 = t1 % mod;
    }
  for (int i = 1; i <= n; i++)
    if (!visited[i]) {
      int u = d[i].second;
      int j = c[u] - i;
      if (d[j].second != u) rev(j);
      int a = d[i].first;
      int b = d[j].first;
      bool fl1 = e[i].second > 0;
      bool fl2 = e[j].second > 0;
      if (fl1 == fl2) {
        d[i].second = d[j].second = e[i].second = e[j].second = 0;
        dfs(i);
        long long z0 = get(i, 0);
        long long z1 = get(i, 1);
        c[a] -= i;
        c[b] -= j;
        int new_i = c[a];
        if (new_i == 0) {
          z0 += 2;
        } else {
          if (d[new_i].second != a) rev(new_i);
          dfs(new_i);
          z0 += get(new_i, 0);
          z1 += get(new_i, 1);
        }
        long long t0 = r0 * z0 + r1 * z1;
        long long t1 = r1 * z0 + r0 * z1;
        r0 = t0 % mod;
        r1 = t1 % mod;
      } else {
        d[i].second = d[j].second = e[i].second = e[j].second = 0;
        c[a] -= i;
        int new_i = c[a];
        if (d[new_i].second != a) rev(new_i);
        dfs(new_i);
        long long z0 = get(new_i, 1);
        long long z1 = get(new_i, 0);
        c[a] += i;
        c[b] -= j;
        int new_j = c[b];
        if (d[new_j].second != b) rev(new_j);
        dfs(new_j);
        z0 += get(new_j, 1);
        z1 += get(new_j, 0);
        long long t0 = r0 * z0 + r1 * z1;
        long long t1 = r1 * z0 + r0 * z1;
        r0 = t0 % mod;
        r1 = t1 % mod;
      }
    }
  for (int i = 1; i <= m; i++)
    if (!vtroka[i]) {
      r1 *= 2;
      r1 %= mod;
    }
  cout << r1 << endl;
  return 0;
}
