#include <bits/stdc++.h>
using namespace std;
const int N = 4001, M = 100;
long long int mod = 1e9 + 7;
long long int dp[N][M][2];
long long int n, l;
pair<long long int, long long int> a[M];
long long int solve(int le, int prev, int ro) {
  if (le == 0) return 1;
  if (le < 0) return 0;
  if (dp[le][prev][ro] != -1) return dp[le][prev][ro];
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    if (le == l) {
      ans = (ans + solve(le - a[i].first, i, 0)) % mod;
      if (a[i].first != a[i].second)
        ans = (ans + solve(le - a[i].second, i, 1)) % mod;
      continue;
    }
    if (i != prev) {
      if (ro && a[prev].first == a[i].first)
        ans = (ans + solve(le - a[i].first, i, 0)) % mod;
      if (ro && a[prev].first == a[i].second && a[i].first != a[i].second)
        ans = (ans + solve(le - a[i].second, i, 1)) % mod;
      if (ro == 0 && a[prev].second == a[i].first)
        ans = (ans + solve(le - a[i].first, i, 0)) % mod;
      if (ro == 0 && a[prev].second == a[i].second && a[i].first != a[i].second)
        ans = (ans + solve(le - a[i].second, i, 1)) % mod;
    }
  }
  return dp[le][prev][ro] = ans;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> n >> l;
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  cout << solve(l, 0, 0) << endl;
}
