#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-5;
const int MOD = int(1e9) + 7, MX = int(5e4) + 1;
long long memo[100][3001][2];
int n, l;
pair<int, int> A[101];
long long dp(int i, int len, int f) {
  if (len == l) return 1;
  if (i == n || len > l) return 0;
  long long &ret = memo[i][len][f];
  if (ret + 1) return ret;
  ret = 0;
  int L = A[i].first, W = A[i].second;
  if (f) swap(L, W);
  for (int j = 0; j < n; j++) {
    if (j != i) {
      if (A[j].first == W)
        ret += dp(j, len + A[j].first, 0);
      else if (A[j].second == W)
        ret += dp(j, len + A[j].second, 1);
      if (ret >= MOD) ret -= MOD;
    }
  }
  return ret;
}
long long sol() {
  memset(memo, -1, sizeof memo);
  long long res = 0;
  for (int i = 0; i < n; i++) {
    res += dp(i, A[i].first, 0) +
           (A[i].first - A[i].second ? dp(i, A[i].second, 1) : 0);
    if (res >= MOD) res -= MOD;
  }
  return res;
}
void solve() {
  scanf("%d %d", &n, &l);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &A[i].first, &A[i].second);
  }
  printf("%lld\n", sol() % MOD);
}
int main() { solve(); }
