#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
struct Node {
  int length, width;
  int type;
};
long long dp[3007][300];
int b[300][300];
Node a[205];
int n, l;
int main() {
  int i, j, k, b, c;
  memset(dp, 0, sizeof dp);
  while (scanf("%d %d", &n, &l) != EOF) {
    getchar();
    int cnt = 0;
    for (i = 1; i <= n; i++) {
      cin >> b;
      cin >> c;
      a[++cnt].length = b;
      a[cnt].width = c;
      a[cnt].type = i;
      dp[b][cnt] = 1;
      if (b != c) {
        cnt++;
        a[cnt].length = c;
        a[cnt].width = b;
        a[cnt].type = i;
        dp[c][cnt] = 1;
      }
    }
    for (i = 1; i <= l; i++) {
      for (j = 1; j <= cnt; j++) {
        if (dp[i][j]) {
          for (k = 1; k <= cnt; k++) {
            if (a[j].type == a[k].type) {
              continue;
            }
            if (a[j].width == a[k].length && (i + a[k].length <= l)) {
              dp[i + a[k].length][k] += dp[i][j];
              dp[i + a[k].length][k] %= MOD;
            }
          }
        }
      }
    }
    long long ans = 0;
    for (i = 1; i <= cnt; i++) {
      ans += dp[l][i];
      ans %= MOD;
    }
    cout << ans;
  }
}
