#include <bits/stdc++.h>
using namespace std;
int const M = 1e9 + 7;
vector<int> a, b;
int dp[3001][100][2], n, l;
int main() {
  scanf("%d%d", &n, &l);
  for (int i = 0; i < n; ++i) {
    int h, w;
    scanf("%d%d", &h, &w);
    a.push_back(h);
    b.push_back(w);
  }
  for (int i = 0; i < n; ++i) {
    ++dp[a[i]][i][0];
    if (a[i] != b[i]) ++dp[b[i]][i][1];
  }
  for (int i = 1; i <= l; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int t = 0; t < 2; ++t) {
        for (int k = 0; k < n; ++k) {
          if (k == j) continue;
          if (t == 0) {
            if (i - a[k] > 0 && a[k] == b[j])
              dp[i][k][0] = (dp[i][k][0] % M + dp[i - a[k]][j][0] % M) % M;
            if (a[k] != b[k] && i - b[k] > 0 && b[k] == b[j])
              dp[i][k][1] = (dp[i][k][1] % M + dp[i - b[k]][j][0] % M) % M;
          } else {
            if (i - a[k] > 0 && a[k] == a[j])
              dp[i][k][0] = (dp[i][k][0] % M + dp[i - a[k]][j][1] % M) % M;
            if (a[k] != b[k] && i - b[k] > 0 && b[k] == a[j])
              dp[i][k][1] = (dp[i][k][1] % M + dp[i - b[k]][j][1] % M) % M;
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
    for (int t = 0; t < 2; ++t) ans = (ans % M + dp[l][i][t] % M) % M;
  printf("%d", ans);
  return 0;
}
