#include <bits/stdc++.h>
using namespace std;
struct fence {
  long long w, l, id;
  fence() {}
  fence(long long ww, long long lll, long long idd) {
    w = ww;
    l = lll;
    id = idd;
  }
} fs[3000];
long long n, l, cnt;
long long dp[4000][3000];
const long long mod = 1000000007;
int main() {
  cin >> n >> l;
  for (long long i = 0; i < n; i++) {
    cin >> fs[cnt].w >> fs[cnt].l;
    fs[cnt].id = i;
    if (fs[cnt].w != fs[cnt].l) {
      ++cnt;
      fs[cnt].w = fs[cnt - 1].l;
      fs[cnt].l = fs[cnt - 1].w;
      fs[cnt].id = i;
    }
    cnt++;
  }
  for (long long i = 0; i < cnt; i++) {
    dp[fs[i].w][i] = (dp[fs[i].w][i] + 1) % mod;
  }
  for (long long i = 1; i <= l; i++) {
    for (long long j = 0; j < cnt; j++) {
      for (long long k = 0; k < cnt; k++) {
        if (fs[j].l == fs[k].w && fs[j].id != fs[k].id && i + fs[k].w <= l) {
          dp[i + fs[k].w][k] += dp[i][j];
          dp[i + fs[k].w][k] %= mod;
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < cnt; i++) {
    ans = (ans + dp[l][i]) % mod;
  }
  cout << ans << endl;
  return 0;
}
