#include <bits/stdc++.h>
using namespace std;
const long long LINF = (long long)1e18;
const int maxL = 3333;
const int maxN = 211;
int dp[maxL][maxN];
const int MOD = (long long)1e9 + 7;
int a[maxN];
int b[maxN];
void add(int &a, int b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
}
int main() {
  int n, l;
  cin >> n >> l;
  for (int i = 0; i < n; i++) {
    cin >> a[i * 2] >> b[i * 2];
    if (a[i * 2] != b[i * 2]) {
      b[i * 2 + 1] = a[i * 2];
      a[i * 2 + 1] = b[i * 2];
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    if (a[i]) dp[a[i]][i] = 1;
  }
  for (int ii = 0; ii <= l; ii++) {
    for (int i = 0; i < 2 * n; i++) {
      for (int j = 0; j < 2 * n; j++) {
        if (i / 2 == j / 2 || !a[i] || !a[j]) continue;
        if (a[i] == b[j]) {
          add(dp[ii + a[j]][j], dp[ii][i]);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < maxN; i++) {
    add(ans, dp[l][i]);
  }
  cout << ans << endl;
  return 0;
}
