#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int MaxL = 4000;
const int MaxN = 300;
int f[MaxL][MaxN];
int ans = 0, n, l, a[MaxN], b[MaxN], nom[MaxN], m;
int main() {
  cin >> n >> l;
  for (int i = 0; i < n; i++) {
    m++;
    cin >> a[m] >> b[m];
    nom[m] = i;
    if (a[m] == b[m]) continue;
    m++;
    a[m] = b[m - 1];
    b[m] = a[m - 1];
    nom[m] = i;
  }
  memset(f, 0, sizeof(f));
  f[0][0] = 1;
  for (int i = 0; i <= l; i++)
    for (int j = 0; j <= m; j++)
      if (f[i][j] != 0) {
        for (int k = 1; k <= m; k++)
          if (nom[k] != nom[j] && b[j] == a[k]) {
            f[i + a[k]][k] = (f[i + a[k]][k] + f[i][j]) % mod;
          } else if (j == 0) {
            f[i + a[k]][k] = (f[i + a[k]][k] + f[i][j]) % mod;
          }
      }
  for (int i = 0; i <= m; i++) ans = (ans + f[l][i]) % mod;
  cout << ans << endl;
}
