#include <bits/stdc++.h>
using namespace std;
long long int dp[3001][101][2];
int n, l;
vector<pair<int, int> > v(101);
long long int calc(long long int len, long long int wid, long long int tr) {
  if (len < 0) return 0;
  if (len == 0) {
    return 1;
  }
  if (dp[len][wid][tr] != -1) return dp[len][wid][tr];
  long long int z = 0, kk;
  if (tr == 0)
    kk = v[wid].second;
  else
    kk = v[wid].first;
  for (int i = 1; i <= n; i++) {
    if (i == wid) continue;
    if (len >= v[i].first && kk == v[i].first) {
      z = (z + calc(len - v[i].first, i, 0)) % 1000000007;
    }
    if (len >= v[i].second && v[i].second == kk && v[i].first != v[i].second) {
      z = (z + calc(len - v[i].second, i, 1)) % 1000000007;
    }
  }
  dp[len][wid][tr] = z;
  return z;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> l;
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    cin >> v[i].first >> v[i].second;
  }
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = (ans + calc(l - v[i].first, i, 0)) % 1000000007;
    if (v[i].first != v[i].second)
      ans = (ans + calc(l - v[i].second, i, 1)) % 1000000007;
  }
  cout << ans;
  return 0;
}
