#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long ans[101][2][3001];
int a[100];
int b[100];
int n;
int l;
long long int DP(int i, int o, int len) {
  long long int suma = 0;
  if (len == 0) {
    return 1;
  } else if (len < 0) {
    return 0;
  } else if (ans[i][o][len] != -1) {
    return ans[i][o][len];
  } else {
    for (int j = 0; j < n; j++) {
      if (j == i) {
        j += 1;
      }
      if (o == 1 and a[j] == a[i]) {
        suma += DP(j, 0, len - a[j]);
      }
      if (o == 0 and a[j] == b[i]) {
        suma += DP(j, 0, len - a[j]);
      }
      if (a[j] != b[j]) {
        if (o == 1 and b[j] == a[i]) {
          suma += DP(j, 1, len - b[j]);
        }
        if (o == 0 and b[j] == b[i]) {
          suma += DP(j, 1, len - b[j]);
        }
      }
    }
  }
  suma = suma % mod;
  ans[i][o][len] = suma;
  return ans[i][o][len];
}
int main() {
  memset(ans, -1, sizeof(ans));
  cin >> n >> l;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  long long int suma = 0;
  for (int i = 0; i < n; i++) {
    suma = (suma + DP(i, 0, l - a[i])) % mod;
    if (a[i] != b[i]) {
      suma = (suma + DP(i, 1, l - b[i])) % mod;
    }
  }
  cout << suma;
}
