#include <bits/stdc++.h>   using namespace std;   int n, A, B;   long long toi(string s) {     istringstream is(s);     long long x;     is >> x;     return x;   }   string tos(long long t) {     stringstream st;     st << t;     return st.str();   }   long long F[1000005], FP[1000005];   bool f(long long x) {     while (x > 0) {       if (x % 10 != A && x % 10 != B) return 0;       x /= 10;     }     return 1;   }   long long pow(long long a, long long b, long long c) {     long long x = 1, y = a;     while (b > 0) {       if (b & 1) x = (x * y) % c;       y = (y * y) % c;       b >>= 1;     }     return x;   }   int main() {     F[0] = 1;     for (int i = 1; i < 1000005; ++i) {       F[i] = i * F[i - 1];       if (F[i] >= 1000000007) F[i] %= 1000000007;     }     FP[1000005 - 1] = pow(F[1000005 - 1], 1000000007 - 2, 1000000007);     for (int i = 1000005 - 2; i >= 0; --i) {       FP[i] = FP[i + 1] * (i + 1);       if (FP[i] >= 1000000007) FP[i] %= 1000000007;     }     while (cin >> A >> B >> n) {       long long cnt = 0;       for (int i = 0; i <= n; ++i)         if (f(i * A + (n - i) * B)) {           long long num = F[n], den = FP[i] * FP[n - i];           if (den >= 1000000007) den %= 1000000007;           num *= den;           if (num >= 1000000007) num %= 1000000007;           cnt += num;           if (cnt >= 1000000007) cnt -= 1000000007;         }       cout << cnt << endl;     }   }   