#include <bits/stdc++.h>
using namespace std;
const int MAX = 200000 + 5;
const long long MOD = 1000000000 + 7;
int rnk[MAX], revrnk[MAX];
pair<int, int> arr[MAX], arr2[MAX], temparr[MAX];
vector<int> places[MAX], pos[MAX];
int n, m;
int dp[MAX][2][2][2];
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (abs(a.first) < abs(b.first)) return 1;
  return abs(a.second) < abs(b.second);
}
int rec(int number, int r, int pp, int p) {
  if (number == m + 1) return r;
  int &ret = dp[number][r][pp][p];
  if (ret != -1) return ret;
  ret = 0;
  vector<int> v;
  for (int i = 0; i < pos[number].size(); i++) {
    int tempi = pos[number][i];
    if (p == 1 && arr2[tempi].first == number - 1 ||
        p == 0 && arr2[tempi].first == -number + 1)
      continue;
    if (p == 1 && arr2[tempi].second == number - 1 ||
        p == 0 && arr2[tempi].second == -number + 1)
      continue;
    if (number != 1 && pp == 1 && arr2[tempi].first == number - 2 ||
        number != 1 && pp == 0 && arr2[tempi].first == -number + 2)
      continue;
    if (number != 1 && pp == 1 && arr2[tempi].second == number - 2 ||
        number != 1 && pp == 0 && arr2[tempi].second == -number + 2)
      continue;
    v.push_back(tempi);
  }
  int change = 0;
  for (int i = 0; i < v.size(); i++) {
    int tempi = v[i];
    if (number == arr2[tempi].first || number == arr2[tempi].second)
      change ^= 1;
  }
  ret = rec(number + 1, r ^ change, p, 1);
  change = 0;
  for (int i = 0; i < v.size(); i++) {
    int tempi = v[i];
    if (-number == arr2[tempi].first || -number == arr2[tempi].second)
      change ^= 1;
  }
  ret += rec(number + 1, r ^ change, p, 0);
  ret %= MOD;
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  memset(dp, -1, sizeof dp);
  cin >> n >> m;
  set<int> not_ranked;
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    int a, b;
    if (k == 1) {
      cin >> a;
      places[abs(a)].push_back(i);
      b = a;
    } else {
      cin >> a >> b;
      places[abs(a)].push_back(i);
      places[abs(b)].push_back(i);
    }
    not_ranked.insert(abs(a));
    not_ranked.insert(abs(b));
    arr[i] = make_pair(a, b);
    temparr[i] = make_pair(abs(a), abs(b));
  }
  int lst = 0;
  while (not_ranked.size()) {
    queue<int> q;
    int temp = *not_ranked.begin();
    rnk[temp] = ++lst;
    revrnk[lst] = temp;
    not_ranked.erase(temp);
    q.push(lst);
    while (q.size()) {
      int cur = q.front();
      q.pop();
      for (int i = 0; i < places[revrnk[cur]].size(); i++) {
        int idx = places[revrnk[cur]][i];
        if (rnk[temparr[idx].first] == 0) {
          rnk[temparr[idx].first] = ++lst;
          revrnk[lst] = temparr[idx].first;
          q.push(lst);
          not_ranked.erase(temparr[idx].first);
        }
        if (rnk[temparr[idx].second] == 0) {
          rnk[temparr[idx].second] = ++lst;
          revrnk[lst] = temparr[idx].second;
          q.push(lst);
          not_ranked.erase(temparr[idx].second);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    arr2[i].first = rnk[temparr[i].first];
    if (arr[i].first < 0) arr2[i].first *= -1;
    arr2[i].second = rnk[temparr[i].second];
    if (arr[i].second < 0) arr2[i].second *= -1;
    if (abs(arr2[i].first) > abs(arr2[i].second))
      swap(arr2[i].first, arr2[i].second);
  }
  sort(arr2 + 1, arr2 + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    pos[abs(arr2[i].first)].push_back(i);
    if (abs(arr2[i].first) != abs(arr2[i].second))
      pos[abs(arr2[i].second)].push_back(i);
  }
  cout << rec(1, 0, 0, 0) << "\n";
  return 0;
}
