Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		seed, _ := strconv.Atoi(scanner.Text())
		fmt.Printf("Case %d:\n", i+1)
		for j := 0; j < 10; j++ {
			tmp := fmt.Sprintf("%08d", seed*seed)
			seed, _ = strconv.Atoi(tmp[2:6])
			fmt.Println(seed)
		}
	}
}

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)

typedef unsigned long long ull;

int main(){
	int n; cin>>n;
	FOR(i,n){
		printf("Case %d:\n",i+1);
		int x; cin>>x;
		FOR(j,10){
			x = (x*x)/100%10000;
			cout << x << endl;
		}
	}

	return 0;
}

C++: //まともに使い方を理解していないくせにincludeしまくる人間のクズ
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>

//using namespace stdしないと表記がめんどくさいからね、仕方ないね
using namespace std;

//可読性を上げるためのdefineが仇となる典型的パターン
#define rep(i,n) for(int i = 0; i < n; i++)

//ローカル変数とグローバル変数は使い分けよう！
short n;
int s;
unsigned long long int ans;

//関数って楽しいよね！（魔王スマイル）
int main(){
    scanf("%d", &n);
    rep(i, n){
        printf("Case %d:\n", i + 1);
        scanf("%d", &s);
        rep(j, 10){
            s *= s;
            s /= 100;
            s = s % 10000;
            printf("%d\n", s);
        }
    }
    return 0;
}

C++: //include
//------------------------------------------
#include <bits/stdc++.h>
 
using namespace std;
 
//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
 
//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
 
//repetition
//------------------------------------------
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
 
//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;
 
// output vector
// ------------------------------------------
namespace std {
    template<typename T> ostream & operator<<(ostream& os, vector<T> const& v){
        for(auto it=v.begin(); it!=v.end(); ++it){
            os << *it << (it+1==v.end() ? "" : ",");
        }
        return os;
    }
}
 
//clear memory
#define clr(a) memset((a), 0 ,sizeof(a))
 
int main(){
    int n;
    ull a;
     
    cin >> n;
     
    rep(i,n){
        cin >> a;
        cout << "Case " << i+1 << ":"<<  endl;
        rep(j,10){
            a=pow(a,2);
            a/=100;
            a%=10000;
            cout << a << endl;
        }
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
//#include <map>
#include <iomanip>
#include <vector>
#include <queue>

using namespace std;



int main()
{
	int n, s;
	char p[9], ne[5];
	
	cin >> n;
	for (int i=1; i<=n; i++)
	{
		cin >> s;
		cout << "Case " << i << ":" << endl;
		for (int j=0; j<10; j++)
		{
			sprintf(p, "%08d", s*s);
			ne[0]=p[2];ne[1]=p[3];ne[2]=p[4];ne[3]=p[5];ne[4]=0;
			printf("%d\n", atoi(ne));
			s = atoi(ne);
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <vector>
using namespace std;
#define N 4
int main(){
    int n,in,tmp;
    cin >> n;
    vector<int> data;
    int t;
    for(int i = 0; i < n; ++i) {
        cout << "Case " << i+1 << ":" << endl;
        cin >> in;
        for(int k = 0; k < 10; ++k) {
            data.clear();
            tmp = pow(in,2);
            for(int j = 0; j < 2*N; ++j) {
                t = pow(10,2*N-j-1);
                if (2*N-N/2 >= j && j >= N/2) {
                    data.push_back(tmp/t);
                }
                tmp = tmp%t;
            }
            int next(0),l(4);
            for(vector<int>::iterator it = data.begin(); it != data.end(); ++it) {
                next += *it * pow(10,--l);
            }
            cout << next << endl;
            in = next;
        }
    }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <string>

using namespace std;

int main(){

	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		cout<<"Case "<<i+1<<":"<<endl;
		int s;
		cin>>s;
		for(int j = 0; j < 10; j++){
			int r=s*s;
			int t=r;
			string ss;
			while(t>0){
				int nn=t%10;
				ss+=(nn+'0');
				t/=10;
			}
			for(int i = ss.size(); i < 8; i++){
				ss+='0';
			}
			reverse(ss.begin(),ss.end());
			// ツ陳可崢４ツづつづ個値ツづーツづづゥ
			s=atoi(ss.substr(2,4).c_str());
			cout<<s<<endl;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    for(int c=0;c<n;c++){
        string in; cin>>in;
        cout<<"Case "<<c<<" "<<endl;
        rep(i,10){
                    int num=pow(stoi(in),2);
                    in=to_string(num);

                string t;
                int cnt=in.size();
                while(cnt++ <8)t.push_back('0');
                t+=in;
                string ans; for(int i=2;i<=6;i++){
                    ans.push_back(t[i]);
                }
                cout<<stoi(ans)<<endl;
            in=ans;
        }
    }
}

C++: #include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>


using namespace std;

int main(void){
	long long int n,s;
	scanf("%lld",&n);
	for(int a=1;a<=n;a++){
		scanf("%lld",&s);
		printf("Case %d:\n",a);
		for(int i=0;i<10;i++){
			char ss[8],sss[4];
			s=s*s;
			sprintf(ss,"%08lld",s);
			int sk=0;
			for(int j=0;j<4;j++){
				if(j>=0){
					sss[j]=ss[2+j];
				}
			}
			s=atoi(sss);
			printf("%lld\n",s);
		}
	}
    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;

#define rep(i, n)for((i) = 0;(i) < (n);++(i))

int main(void){
	int i, j, q, n;
	scanf("%d", &q);
	rep(i, q){
		printf("Case %d:\n", i + 1);
		scanf("%d", &n);
		for(int t = 10;t--;){
			n = (n * n / 100) % 10000;
			printf("%d\n", n);
		}
	}
}