#include <bits/stdc++.h>
static const int INF = std::numeric_limits<int>::max();
int MOD = 1000000007;
int dp[3001][100][2];
int main() {
  int n, L;
  std::cin >> n >> L;
  std::vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i] >> b[i];
  }
  dp[0][0][0] = 1;
  for (int i = 0; i < L; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int k = 0; k < 2; ++k) {
        if (dp[i][j][k] == 0) continue;
        int pre_width = k == 0 ? a[j] : b[j];
        for (int l = 0; l < n; ++l) {
          if (i > 0 && j == l) continue;
          int width = a[l], length = b[l];
          for (int m = 0; m < 2; ++m) {
            if ((i == 0 || pre_width == length) && i + length <= L) {
              dp[i + length][l][m] += dp[i][j][k];
              dp[i + length][l][m] %= MOD;
            }
            if (width == length) break;
            std::swap(width, length);
          }
        }
      }
    }
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 2; ++j) {
      res += dp[L][i][j];
      res %= MOD;
    }
  }
  std::cout << res << std::endl;
}
