#include <bits/stdc++.h>
const int N = 1e2, MOD = 1e9 + 7;
using namespace std;
int n, l, A[N + 9], B[N + 9], mem[109][3009][3];
int add(int a, int b) {
  int s = (a >= MOD ? a - MOD : a) + (b >= MOD ? b - MOD : b);
  return (s >= MOD ? s - MOD : s);
}
int solve(int last = 0, int len = 0, bool is_rot = 0) {
  if (len > l) return 0;
  if (len == l) return 1;
  int &ret = mem[last][len][is_rot];
  if (~ret) return ret;
  ret = 0;
  for (int j = 1; j <= n; ++j) {
    if (j == last) continue;
    if (!last)
      ret =
          add(ret, solve(j, A[j], 0) + (A[j] != B[j] ? solve(j, B[j], 1) : 0));
    else if (!is_rot && A[j] == B[last])
      ret = add(ret, (len + A[j] <= l ? solve(j, len + A[j], 0) : 0));
    else if (!is_rot && B[j] == B[last])
      ret = add(ret, (len + B[j] <= l ? solve(j, len + B[j], 1) : 0));
    else if (is_rot && A[j] == A[last])
      ret = add(ret, (len + A[j] <= l ? solve(j, len + A[j], 0) : 0));
    else if (is_rot && B[j] == A[last])
      ret = add(ret, (len + B[j] <= l ? solve(j, len + B[j], 1) : 0));
  }
  return ret;
}
int main() {
  memset(mem, -1, sizeof mem);
  scanf("%d %d", &n, &l);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &A[i], &B[i]);
  printf("%d\n", solve());
  return 0;
}
