Devu and Lucky Numbers 
Difficulty: Hard

You are given three integers $x$, $y$ and $z$. You have to find the sum of all numbers whose digits are made of only $4$, $5$ and $6$, that have at most $x$ fours in decimal representation, at most $y$ fives in decimal representation and at most $z$ sixes in decimal representation. As summation can be very large, print it modulo $10^9+7$.  

**Input Format**  
The only line containing three space-separated integers $x$, $y$ and $z$.  

**Constraints**  
$ 0\le x \le 100$  
$ 0\le y \le 100$  
$ 0\le z \le 100$  

**Output Format**  
Output the summation modulo $10^9+7$.  
 
**Sample Input#0**  

    1 1 1

**Sample Output#0**  

 	3675

**Sample Input#1**  

    1 2 3

**Sample Output#1**  

 	39345806


**Explanation**  
For the given input:  
$$4 + 5 +6 + 45+ 54+56+65+46+64 + 456+465+546+564+645+654 = 3675$$  

Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:


Reference solution (C++):
    #include <cmath>
    #include <cstdio>
    #include <vector>
    #include <iostream>
    #include <algorithm>
    #include <bits/stdc++.h>
    using namespace std;
    const int mod = 1e9 + 7 ;
    int x , y , z ;
    int dp[101][101][101] ,cnt[101][101][101];


    int solve1(int x,int y,int z){
        if(x <= 0 && y <= 0 && z <= 0)
            return 1 ;
        int &ret = cnt[x][y][z] ;
        if(ret != -1) return ret ;
        ret = 0 ;
        if(x)
            ret += solve1(x-1,y,z) ;
        if(ret >= mod) ret -= mod ; 
        if(y)
            ret += solve1(x,y-1,z) ;
        if(ret >= mod) ret -= mod ; 
        if(z)
            ret += solve1(x,y,z-1) ;
        if(ret >= mod) ret -= mod ; 
        return ret ;
    }

    int solve(int x,int y,int z){
        if( x <= 0 && y <= 0 && z <= 0 )
            return 0 ;
        int &ret = dp[x][y][z] ;
        if(ret != -1)
            return ret ;
        ret = 0 ; 
        if(x)
            ret += (1LL* solve(x-1,y,z) * 10 + 1LL * 4 * solve1(x-1,y,z)) % mod ;
        if(ret >= mod) ret -= mod ; 
        if(y)
            ret += (1LL* solve(x,y-1,z) * 10 + 1LL * 5 * solve1(x,y-1,z)) % mod ;
        if(ret >= mod) ret -= mod ; 
        if(z)
            ret += (1LL* solve(x,y,z-1) * 10 + 1LL * 6 * solve1(x,y,z-1)) % mod ;
        if(ret >= mod) ret -= mod ;
        return ret ;
    }
    int main() {
        cin >> x >> y >> z ;
        memset(dp,-1,sizeof dp) ;
        memset(cnt,-1,sizeof cnt) ;
        int ans = 0 ;
        for(int i=0;i<=x;i++)
            for(int j=0;j<=y;j++)
                for(int k=0;k<=z;k++){
                    ans += solve(i,j,k) ;
                    if(ans >= mod) ans -= mod ; 
                }
        cout << ans << endl ;
        return 0;
    }