#include <bits/stdc++.h>
using namespace std;
int dp[107][3007][5];
int n, l;
int a[107], b[107];
int main() {
  while (scanf("%d%d", &n, &l) != EOF) {
    for (int i = 0; i < n; i++) scanf("%d%d", &a[i], &b[i]);
    memset(dp, 0, sizeof dp);
    for (int i = 0; i < n; i++) {
      dp[i][a[i]][0] = 1;
      if (a[i] != b[i]) dp[i][b[i]][1] = 1;
    }
    for (int j = 0; j <= l; j++)
      for (int i = 0; i < n; i++) {
        for (int k = 0; k < n; k++) {
          if (i == k) continue;
          if (a[i] != b[i]) {
            if (b[i] == a[k] && j - a[i] >= 0)
              dp[i][j][0] += dp[k][j - a[i]][0];
            dp[i][j][0] %= 1000000007;
            if (b[i] == b[k] && j - a[i] >= 0)
              dp[i][j][0] += dp[k][j - a[i]][1];
            dp[i][j][0] %= 1000000007;
            if (a[i] == a[k] && j - b[i] >= 0)
              dp[i][j][1] += dp[k][j - b[i]][0];
            dp[i][j][1] %= 1000000007;
            if (a[i] == b[k] && j - b[i] >= 0)
              dp[i][j][1] += dp[k][j - b[i]][1];
            dp[i][j][1] %= 1000000007;
          } else if (a[i] == b[i]) {
            if (b[i] == a[k] && j - a[i] >= 0)
              dp[i][j][0] += dp[k][j - a[i]][0];
            dp[i][j][0] %= 1000000007;
            if (b[i] == b[k] && j - a[i] >= 0)
              dp[i][j][0] += dp[k][j - a[i]][1];
            dp[i][j][0] %= 1000000007;
          }
        }
      }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      ans += dp[i][l][0];
      ans %= 1000000007;
      ans += dp[i][l][1];
      ans %= 1000000007;
    }
    printf("%d\n", ans);
  }
  return 0;
}
