#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int N, L;
int board[105][2];
int dp[3005][105][2];
int main() {
  cin >> N >> L;
  for (int i = 0; i < N; i++) cin >> board[i][0] >> board[i][1];
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 2; j++) dp[board[i][j]][i][j] = 1;
  for (int i = 1; i <= L; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < 2; k++)
        if (i - board[j][k] >= 0)
          for (int m = 0; m < N; m++)
            if (j != m) {
              if (board[m][k ^ 1] == board[j][k])
                dp[i][j][k] = (dp[i][j][k] + dp[i - board[j][k]][m][k]) % MOD;
              else if (board[m][k] == board[j][k])
                dp[i][j][k] =
                    (dp[i][j][k] + dp[i - board[j][k]][m][k ^ 1]) % MOD;
            }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = (ans + dp[L][i][0]) % MOD;
    if (board[i][0] != board[i][1]) ans = (ans + dp[L][i][1]) % MOD;
  }
  cout << ans << "\n";
  return 0;
}
