#include <bits/stdc++.h>
using namespace std;
int n, l;
long long int memo[105][2][3005];
pair<int, int> type[105];
long long int dp(const int i, const bool d, const int j) {
  if (j < 0) return 0LL;
  if (memo[i][d][j] != -1) return memo[i][d][j];
  long long int ans = 0;
  int prev_wid = d ? type[i].first : type[i].second;
  for (int k = 0; k < n; ++k) {
    if (k == i) continue;
    pair<int, int> tmp = type[k];
    if (tmp.first == prev_wid)
      ans = (ans + dp(k, false, j - prev_wid)) % 1000000007LL;
    else if (tmp.second == prev_wid)
      ans = (ans + dp(k, true, j - prev_wid)) % 1000000007LL;
  }
  return memo[i][d][j] = ans;
}
inline void init(void) {
  memset(memo, 0xFF, sizeof memo);
  for (int i = 0; i < 105; ++i) memo[i][0][0] = memo[i][1][0] = 1LL;
}
int main(void) {
  init();
  scanf("%d%d", &n, &l);
  for (int i = 0, x, y; i < n; ++i) {
    scanf("%d%d", &x, &y);
    type[i] = pair<int, int>(x, y);
  }
  long long int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans = (ans + dp(i, true, l - type[i].second)) % 1000000007LL;
    if (type[i].first != type[i].second)
      ans = (ans + dp(i, false, l - type[i].first)) % 1000000007LL;
  }
  cout << ans;
  return 0;
}
