#include <bits/stdc++.h>
using namespace std;
int len[102][2], width[102][2], n;
long long memo[102][2][3002];
long long DP(int last, int id, int l) {
  if (l < 0) return 0;
  if (l == 0) return 1;
  long long &ret = memo[last][id][l];
  if (ret != -1) return ret;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == last) continue;
    if (len[i][0] == width[last][id])
      ans = (ans + DP(i, 0, l - len[i][0])) % 1000000007;
    else if (len[i][1] == width[last][id])
      ans = (ans + DP(i, 1, l - len[i][1])) % 1000000007;
  }
  return ret = ans;
}
int main() {
  int l;
  while (cin >> n >> l) {
    for (int i = 0; i < n; i++) {
      cin >> len[i][0] >> width[i][0];
      len[i][1] = width[i][0];
      width[i][1] = len[i][0];
    }
    memset(memo, -1, sizeof memo);
    long long ans = 0;
    for (int i = n - 1; i >= 0; i--) {
      ans = (ans + DP(i, 0, l - len[i][0])) % 1000000007;
      if (len[i][1] != width[i][1])
        ans = (ans + DP(i, 1, l - len[i][1])) % 1000000007;
    }
    cout << ans << endl;
  }
}
