#include <bits/stdc++.h>
using namespace std;
long long mod = (1e9) + 7;
long long dp[3001][203];
vector<pair<int, int> > board;
vector<int> bi[101];
int N, L;
void modadd(long long& a, long long b) { a = (a + b) % mod; }
int main() {
  scanf("%d %d", &N, &L);
  for (int i = 0; i < N; i++) {
    int w, l;
    scanf("%d %d", &w, &l);
    board.emplace_back(w, l);
    bi[w].push_back(i);
    if (w != l) bi[l].push_back(i);
  }
  for (int i = 0; i < N; i++) {
    if (board[i].first <= L) dp[board[i].first][i << 1]++;
    if (board[i].first != board[i].second && board[i].second <= L) {
      dp[board[i].second][i << 1 | 1]++;
    }
  }
  for (int len = 1; len < L; len++) {
    for (int i = 0; i < N << 1; i++) {
      int prevw = i % 2 == 1 ? board[i >> 1].first : board[i >> 1].second;
      for (int j = 0; j < N; j++) {
        if (i >> 1 == j) continue;
        if (board[j].first == prevw && len + board[j].first <= L) {
          modadd(dp[len + board[j].first][j << 1], dp[len][i]);
        }
        if (board[j].first != board[j].second && board[j].second == prevw &&
            len + board[j].second <= L) {
          modadd(dp[len + board[j].second][j << 1 | 1], dp[len][i]);
        }
      }
    }
  }
  long long ret = 0;
  for (int i = 0; i < N << 1; i++) {
    modadd(ret, dp[L][i]);
  }
  printf("%lld", ret);
}
