#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100;
const int MAXL = 3000;
const int MOD = 1e9 + 7;
int DP[2 * MAXN + 1][MAXL + 1];
vector<pair<int, pair<int, int>>> types;
int N, L, a, b;
int dp(int n, int l) {
  if (l < 0) return 0;
  if (DP[n][l] != -1) return DP[n][l];
  int ans = 0;
  for (int i = 0; i < types.size(); i++) {
    if (types[i].first != types[n].first &&
        types[n].second.first == types[i].second.second)
      ans = (ans + dp(i, l - types[i].second.second)) % MOD;
  }
  return DP[n][l] = ans;
}
int main() {
  memset(DP, -1, sizeof(DP));
  cin >> N >> L;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    types.emplace_back(i, make_pair(a, b));
    if (a != b) types.emplace_back(i, make_pair(b, a));
  }
  for (int i = 0; i < 2 * N; i++) DP[i][0] = 1;
  int ans = 0;
  for (int i = 0; i < types.size(); i++) {
    ans = (ans + dp(i, L - types[i].second.second)) % MOD;
  }
  cout << ans << endl;
  return 0;
}
