#include #include #include using namespace std; struct Node { int val; int depth; Node(int v, int d) { val = v; depth = d; } std::vector children; }; long countArray(int n, int k, int x) { // Return the number of ways to fill in the array. //bfs std::queue nodes; int depth = 0; int count = 0; for (int i = 1; i < n; i++) { if (i != x) { nodes.push(Node(i, 1)); } } while (!nodes.empty()) { Node cur = nodes.front(); nodes.pop(); if (cur.depth == n-2) { if (cur.val != 1) { count = (count+1) % 1000000007; continue; } } else { for (int i = 1; i < n; i++) { if (i != cur.val) { nodes.push(Node(i, cur.depth+1)); } } } } return count; } int main() { int n; int k; int x; cin >> n >> k >> x; long answer = countArray(n, k, x); cout << answer << endl; return 0; }