#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 100 + 5;
const long long MOD = 1000000007;
long long dp[MAX_N][3000 + 10][MAX_N];
vector<pair<long long, long long> > adj[MAX_N];
long long REC(long long s, long long p, long long l) {
  if (p == 0) return 1LL;
  if (p < 0) return 0LL;
  if (dp[s][p][l] != -1) return dp[s][p][l];
  dp[s][p][l] = 0;
  for (long long i = 0; i < adj[s].size(); i++) {
    if (adj[s][i].second != l)
      dp[s][p][l] += REC(adj[s][i].first, p - s, adj[s][i].second);
    dp[s][p][l] %= MOD;
  }
  return dp[s][p][l];
}
int main(void) {
  memset(dp, -1, sizeof dp);
  long long n, l;
  cin >> n >> l;
  vector<pair<long long, long long> > v;
  for (long long i = 0; i < n; i++) {
    pair<long long, long long> T;
    cin >> T.first >> T.second;
    v.push_back(T);
  }
  for (long long i = 0; i < v.size(); i++) {
    adj[v[i].first].push_back(make_pair(v[i].second, i));
    if (v[i].second != v[i].first)
      adj[v[i].second].push_back(make_pair(v[i].first, i));
  }
  long long ans = 0;
  for (long long i = 0; i < v.size(); i++) {
    ans += REC(v[i].second, l - v[i].first, i);
    if (v[i].second != v[i].first) ans += REC(v[i].first, l - v[i].second, i);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
