Simply Loopy

Given an integer n, print what the following function (written in C++) will return: long long unsigned lol(int n) { long long unsigned ret = 0 , i , j , k , l , m , M = 7477777 ; for( i = 1 ; i <= n ; i++ ) for( j = 1 ; j <= n ; j++ ) for( k = 1 ; k <= n ; k++ ) for( l = 1 ; l <= n ; l++ ) return ret ; } Input for( m=1 ; m <= n ; m++ ) if( i + j + k + l + m == n ) ret = (ret + ii + jj + kk + ll + m*m)%M ; First line of input will contain the number of test cases, T ≤ 600. Then there follows T lines, each containing an integer n (1 ≤ n ≤ 105). Output For each case, print the case number starting from 1 and the value returned by the function ‘lol(n)’. See the sample output for exact formatting. Note: A straight forward implementation of the given function may take millions of years, even for the fastest computers! Sample Input 3 5 6 7 Sample Output Case 1: 5 Case 2: 40 Case 3: 175