#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[111];
long long int dp[105][105][3010];
int n, l;
long long int cal(int pre, int ind, int rem) {
  if (rem == 0) return 1;
  if (rem < 0) return 0;
  long long int &ret = dp[pre][ind][rem];
  if (ret != -1) return ret;
  ret++;
  for (int i = 0; i < n; i++) {
    if (i == ind) continue;
    if (a[i].second == pre) ret += cal(a[i].first, i, rem - a[i].second);
    if (a[i].first == pre && a[i].first != a[i].second)
      ret += cal(a[i].second, i, rem - a[i].first);
    ret %= 1000000007;
  }
  return ret % 1000000007;
}
int main() {
  cin >> n >> l;
  for (int i = 0; i < n; i++) scanf("%d%d", &a[i].first, &a[i].second);
  long long int ans = 0;
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < n; i++) {
    ans += cal(a[i].first, i, l - a[i].second);
    if (a[i].first != a[i].second) ans += cal(a[i].second, i, l - a[i].first);
    ans %= 1000000007;
  }
  cout << ans % 1000000007;
}
