#include <bits/stdc++.h>
using namespace std;
const int N = 105, M = 502, INF = 1000 * 1000 * 1000 + 7;
const long double eps = 1e-10;
long double dist(pair<long double, long double> a,
                 pair<long double, long double> b) {
  return sqrt((a.first - b.first) * (a.first - b.first) +
              (a.second - b.second) * (a.second - b.second));
}
unsigned long long z[N][2][3005];
int main() {
  int n, l;
  cin >> n >> l;
  vector<vector<int>> a;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    a[i].resize(2);
    cin >> a[i][0] >> a[i][1];
  }
  for (int i = 0; i < n; ++i) {
    z[i][0][a[i][0]] = 1;
    z[i][1][a[i][1]] = 1;
  }
  for (int len = 1; len < l; len++) {
    for (int i = 0; i < n; ++i) {
      for (int type = 0; type < 2; ++type) {
        if (type == 1 && a[i][0] == a[i][1]) continue;
        if (!z[i][type][len]) continue;
        z[i][type][len] %= INF;
        for (int next = 0; next < n; ++next) {
          if (next == i) continue;
          for (int nextype = 0; nextype < 2; ++nextype) {
            if (nextype == 1 && a[next][0] == a[next][1]) continue;
            if (a[i][type ^ 1] == a[next][nextype]) {
              z[next][nextype][len + a[next][nextype]] += z[i][type][len];
            }
          }
        }
      }
    }
  }
  unsigned long long ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int type = 0; type < 2; ++type) {
      if (type == 1 && a[i][0] == a[i][1]) continue;
      ans += z[i][type][l];
      ans %= INF;
    }
  }
  cout << ans;
  return 0;
}
