#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return a > val ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
inline long long isqrt(long long k) {
  long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
const int maxn = 100000 + 10;
int n, m;
int k[maxn];
int a[maxn][2];
int b[maxn];
vector<int> g[maxn];
vector<pair<int, int> > adj[maxn];
int vis[maxn];
int f[maxn][2][2];
int dp[maxn][2];
vector<pair<int, pair<int, int> > > his;
void clear() {
  while (int((his).size())) {
    int u = his.back().first;
    int aa = his.back().second.first;
    int b = his.back().second.second;
    f[u][aa][b] = -1;
    his.pop_back();
  }
}
int calc(int u, int x, int y, int pv, int bg, int val) {
  if (u == bg) return x == 0 && y == val;
  vis[u] = 1;
  his.push_back(make_pair(u, make_pair(x, y)));
  int& res = f[u][x][y];
  if (~res) return res;
  res = 0;
  if (k[u] == 1) {
    if (a[u][0] > 0)
      return res = x == y;
    else
      return res = x == (y ^ 1);
  } else {
    if (abs(a[u][0]) != (pv >> 1)) swap(a[u][0], a[u][1]);
    int t = y;
    if (a[u][0] < 0) t = y ^ 1;
    if (int((adj[u]).size()) == 1) {
      if (!x && t) return res;
      if (t) return res = 2;
      return res = 1;
    }
    if (adj[u][0].second == (pv ^ 1)) {
      swap(adj[u][0], adj[u][1]);
    }
    int v = adj[u][0].first;
    int w = adj[u][0].second;
    if (a[u][1] > 0) {
      addmod(res, calc(v, x ^ (0 | t), 0, w, bg, val));
      addmod(res, calc(v, x ^ (1 | t), 1, w, bg, val));
    } else {
      addmod(res, calc(v, x ^ (1 | t), 0, w, bg, val));
      addmod(res, calc(v, x ^ (0 | t), 1, w, bg, val));
    }
  }
  return res;
}
void solve() {
  cin >> n >> m;
  for (int i = (0); i < (n); i++) {
    cin >> k[i];
    for (int j = (0); j < (k[i]); j++) {
      cin >> a[i][j];
      g[abs(a[i][j])].push_back(i);
      b[abs(a[i][j])] = 1;
    }
  }
  for (int i = (1); i < (m + 1); i++) {
    if (int((g[i]).size()) == 2) {
      int u = g[i][0];
      int v = g[i][1];
      adj[u].push_back(make_pair(v, i << 1));
      adj[v].push_back(make_pair(u, i << 1 | 1));
    }
  }
  memset(f, -1, sizeof(f));
  vector<pair<int, int> > vv;
  for (int i = (0); i < (n); i++)
    if (!vis[i] && int((adj[i]).size()) == 1) {
      int r0 = 0, r1 = 0;
      if (k[i] == 1) {
        int v = adj[i][0].first;
        int w = adj[i][0].second;
        for (int x = (0); x < (2); x++) {
          int xx = x;
          if (a[i][0] < 0) xx ^= 1;
          clear();
          addmod(r0, calc(v, xx ^ 0, x, w, i, x));
          addmod(r1, calc(v, xx ^ 1, x, w, i, x));
        }
      } else {
        int v = adj[i][0].first;
        int w = adj[i][0].second;
        if (abs(a[i][0]) == (w >> 1)) {
          swap(a[i][0], a[i][1]);
        }
        for (int x = (0); x < (2); x++)
          for (int y = (0); y < (2); y++) {
            int xx = x, yy = y;
            if (a[i][0] < 0) xx ^= 1;
            if (a[i][1] < 0) yy ^= 1;
            clear();
            addmod(r0, calc(v, (xx | yy) ^ 0, y, w, i, x));
            addmod(r1, calc(v, (xx | yy) ^ 1, y, w, i, x));
          }
      }
      vv.push_back(make_pair(r0, r1));
    }
  for (int i = (0); i < (n); i++)
    if (!vis[i] && int((adj[i]).size()) == 2) {
      int r0 = 0, r1 = 0;
      int v = adj[i][0].first;
      int w = adj[i][0].second;
      if (abs(a[i][0]) == (w >> 1)) {
        swap(a[i][0], a[i][1]);
      }
      for (int x = (0); x < (2); x++)
        for (int y = (0); y < (2); y++) {
          int xx = x, yy = y;
          if (a[i][0] < 0) xx ^= 1;
          if (a[i][1] < 0) yy ^= 1;
          clear();
          addmod(r0, calc(v, (xx | yy) ^ 0, y, w, i, x));
          addmod(r1, calc(v, (xx | yy) ^ 1, y, w, i, x));
        }
      vv.push_back(make_pair(r0, r1));
    }
  for (int i = (0); i < (n); i++)
    if (!vis[i] && !int((adj[i]).size())) {
      if (k[i] == 1) {
        vv.push_back(make_pair(1, 1));
      } else {
        vv.push_back(make_pair(1, 3));
      }
    }
  dp[0][0] = 1;
  for (int i = (1); i < (int((vv).size()) + 1); i++) {
    dp[i][0] = mult(dp[i - 1][0], vv[i - 1].first);
    addmod(dp[i][0], mult(dp[i - 1][1], vv[i - 1].second));
    dp[i][1] = mult(dp[i - 1][1], vv[i - 1].first);
    addmod(dp[i][1], mult(dp[i - 1][0], vv[i - 1].second));
  }
  int ans = dp[int((vv).size())][1];
  for (int i = (1); i < (m + 1); i++) {
    if (!b[i]) {
      ans = mult(ans, 2);
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
