#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const long long MOD = 1e9 + 7;
long long dp[3005][105][2];
int n, l, A[105], B[105];
long long ans = 0;
void work() {
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    dp[A[i]][i][0] = 1;
    if (B[i] != A[i]) dp[B[i]][i][1] = 1;
  }
  for (int i = 1; i <= l; i++)
    for (int j = 1; j <= n; j++)
      for (int h = 0; h <= 1; h++)
        if (dp[i][j][h]) {
          for (int k = 1; k <= n; k++)
            if (k != j) {
              if (i + A[k] <= l && A[k] == (h == 0 ? B[j] : A[j]))
                dp[i + A[k]][k][0] = (dp[i + A[k]][k][0] + dp[i][j][h]) % MOD;
              if (A[k] != B[k] && i + B[k] <= l &&
                  B[k] == (h == 0 ? B[j] : A[j]))
                dp[i + B[k]][k][1] = (dp[i + B[k]][k][1] + dp[i][j][h]) % MOD;
            }
        }
  for (int i = 1; i <= n; i++) ans = (ans + dp[l][i][0] + dp[l][i][1]) % MOD;
}
int main() {
  scanf("%d%d", &n, &l);
  for (int i = 1; i <= n; i++) scanf("%d%d", &A[i], &B[i]);
  work();
  cout << ans << endl;
}
