#include <bits/stdc++.h>
int a[205][3];
int res[3005][205];
int main(void) {
  int n, l;
  scanf("%d%d", &n, &l);
  int k = n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i][0], &a[i][1]);
    a[i][2] = i;
    if (a[i][0] != a[i][1]) {
      a[k][0] = a[i][1];
      a[k][1] = a[i][0];
      a[k++][2] = i;
    }
  }
  for (int i = 0; i < k; i++) res[0][i] = 1;
  for (int i = 1; i <= l; i++) {
    for (int j = 0; j < k; j++) {
      res[i][j] = 0;
      if (i < a[j][0]) continue;
      if (i == a[j][0]) {
        res[i][j] = 1;
        continue;
      }
      for (int m = 0; m < k; m++)
        if (a[j][2] != a[m][2] && a[j][0] == a[m][1]) {
          res[i][j] = (res[i][j] + res[i - a[j][0]][m]) % 1000000007;
        }
    }
  }
  int sum = 0;
  for (int i = 0; i < 2 * n; i++) sum = (sum + res[l][i]) % 1000000007;
  printf("%d", sum);
  return 0;
}
