#include <bits/stdc++.h>
using namespace ::std;
const long long maxn = 210;
const long long maxl = 3100;
const long long mod = 1e9 + 7;
pair<long long, long long> a[maxn];
long long q[maxn];
long long dp[maxl][maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, l;
  cin >> n >> l;
  for (long long i = 0; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    if (v == u) {
      a[i] = make_pair(v, u);
      q[i] = maxn;
    } else {
      a[i] = make_pair(v, u);
      q[i] = i + 1;
      i++;
      n++;
      a[i] = make_pair(u, v);
      q[i] = i - 1;
    }
  }
  for (long long i = 1; i <= l; i++) {
    for (long long j = 0; j < n; j++) {
      if (a[j].first == i) {
        dp[i][j] = 1;
      } else if (a[j].first < i) {
        for (long long p = 0; p < n; p++) {
          if (p != j && q[j] != p && a[j].first == a[p].second) {
            dp[i][j] += dp[i - a[j].first][p];
            dp[i][j] %= mod;
          }
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    ans += dp[l][i];
    ans %= mod;
  }
  cout << ans;
}
