#include <bits/stdc++.h>
using namespace std;
int n, l;
pair<int, int> p[102];
int dp[3003][102][2];
int gao() {
  memset(dp, 0, sizeof(dp));
  for (int j = 0; j < n; j++) {
    dp[p[j].first][j][0] = 1;
    if (p[j].first != p[j].second) {
      dp[p[j].second][j][1] = 1;
    }
  }
  for (int i = 1; i <= l; i++) {
    for (int j = 0; j < n; j++) {
      for (int d = 0; d < 2; d++) {
        int width = (d == 0) ? p[j].second : p[j].first;
        for (int k = 0; k < n; k++) {
          int gg = p[k].first == p[k].second ? 1 : 2;
          for (int g = 0; g < gg; g++) {
            int length = (g == 0) ? p[k].first : p[k].second;
            if (j == k || width != length) {
              continue;
            }
            if (i + length < 3003) {
              dp[i + length][k][g] += dp[i][j][d];
              dp[i + length][k][g] %= 1000000007;
            }
          }
        }
      }
    }
  }
  int ans = 0;
  for (int j = 0; j < n; j++) {
    ans += dp[l][j][0];
    ans %= 1000000007;
    ans += dp[l][j][1];
    ans %= 1000000007;
  }
  return ans;
}
int main() {
  while (scanf("%d %d", &n, &l) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%d %d", &p[i].first, &p[i].second);
    }
    int ans = gao();
    printf("%d\n", ans);
  }
  return 0;
}
