#include <bits/stdc++.h>
using namespace std;
const long long M = 1000000007;
long long dp[102][3002][2];
vector<pair<int, bool> > g[100][2];
int fence[100][2];
long long solve(int reml, int p, int b) {
  long long &r = dp[p][reml][b];
  if (r != -1LL) return r;
  if (reml == 0) return r = 1;
  r = 0;
  for (auto a : g[p][b]) {
    if (reml >= fence[a.first][a.second])
      r += solve(reml - fence[a.first][a.second], a.first, a.second);
    r %= M;
  }
  return r % M;
}
int main() {
  int n, l;
  cin >> n >> l;
  for (int i = 0; i < n; i++) cin >> fence[i][0] >> fence[i][1];
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j == i) continue;
      if (fence[i][0] == fence[j][1]) g[i][0].push_back({j, 0});
      if (fence[i][1] == fence[j][0]) g[i][1].push_back({j, 1});
      if (fence[j][0] != fence[j][1] && fence[i][0] == fence[j][0])
        g[i][0].push_back({j, 1});
      if (fence[j][0] != fence[j][1] && fence[i][1] == fence[j][1])
        g[i][1].push_back({j, 0});
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (fence[i][0] != fence[i][1]) {
      if (fence[i][0] <= l) {
        ans += solve(l - fence[i][0], i, 0);
      }
      if (fence[i][1] <= l) {
        ans += solve(l - fence[i][1], i, 1);
      }
    } else if (fence[i][0] <= l)
      ans += solve(l - fence[i][0], i, 0);
  }
  cout << ans % M;
  return 0;
}
