#include <bits/stdc++.h>
using namespace std;
const int MAXL = 3001;
const int MAXN = 101;
const int MOD = 1000000007;
int dp[MAXL][MAXN][2];
int ar[MAXN], br[MAXN];
int n, l, ans;
void init() { ans = 0; }
void input() {
  scanf("%d %d", &n, &l);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &ar[i], &br[i]);
  }
}
void output() { printf("%d\n", ans); }
void solved() {
  for (int i = 0; i < n; ++i) {
    dp[ar[i]][i][0] = 1;
    if (ar[i] != br[i]) dp[br[i]][i][1] = 1;
  }
  for (int cl = 1; cl <= l; ++cl) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == j) continue;
        if (cl - ar[i] >= 0) {
          if (ar[i] == br[j]) {
            dp[cl][i][0] = (dp[cl][i][0] + dp[cl - ar[i]][j][0]) % MOD;
          }
          if (ar[i] == ar[j]) {
            dp[cl][i][0] = (dp[cl][i][0] + dp[cl - ar[i]][j][1]) % MOD;
          }
        }
        if (ar[i] == br[i]) continue;
        if (cl - br[i] >= 0) {
          if (br[i] == br[j]) {
            dp[cl][i][1] = (dp[cl][i][1] + dp[cl - br[i]][j][0]) % MOD;
          }
          if (br[i] == ar[j]) {
            dp[cl][i][1] = (dp[cl][i][1] + dp[cl - br[i]][j][1]) % MOD;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int z = 0; z < 2; ++z) {
      ans = (ans + dp[l][i][z]) % MOD;
    }
  }
}
int main() {
  init();
  input();
  solved();
  output();
  return 0;
}
