#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > woods;
int n, l;
long long memo[105][105][3005];
long long solve(int i, int width, int length) {
  if (i == n || length > l) return 0;
  if (length == l) return 1;
  if (memo[i][width][length] != -1) return memo[i][width][length];
  long long ans = 0;
  for (int a = 0; a < n; a++) {
    ans %= 1000000007;
    if (a != i)
      if (woods[a].first == width)
        ans += solve(a, woods[a].second, length + woods[a].first);
      else if (woods[a].second == width)
        ans += solve(a, woods[a].first, length + woods[a].second);
  }
  return memo[i][width][length] = ans;
}
int main(int argc, const char* argv[]) {
  memset(memo, -1, sizeof(memo));
  cin >> n >> l;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    woods.push_back(make_pair(a, b));
  }
  long long ret = 0;
  for (int i = 0; i < n; i++) {
    ret += solve(i, woods[i].first, woods[i].second);
    if (woods[i].first != woods[i].second)
      ret += solve(i, woods[i].second, woods[i].first);
  }
  cout << ret % 1000000007 << endl;
  return 0;
}
