#include <bits/stdc++.h>
typedef struct {
  int a, b, z;
} ele;
ele g[300];
int nn;
int dp[200][4000] = {0};
int main() {
  int n, l, i, j, k;
  scanf("%d %d", &n, &l);
  nn = 0;
  for (i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    g[nn++] = (ele){x, y, i};
    if (x != y) g[nn++] = (ele){y, x, i};
  }
  for (i = 0; i < nn; i++) dp[i][g[i].a] = 1;
  for (k = 1; k <= l; k++) {
    for (i = 0; i < nn; i++) {
      for (j = 0; j < nn; j++) {
        if (g[j].z == g[i].z) continue;
        if (g[i].a == g[j].b && k - g[i].a >= 0)
          dp[i][k] = (dp[i][k] + dp[j][k - g[i].a]) % 1000000007;
      }
    }
  }
  int ans = 0;
  for (i = 0; i < nn; i++) ans = (ans + dp[i][l]) % 1000000007;
  printf("%d\n", ans);
  return 0;
}
