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++: #include<iostream>
using namespace std;

int main(){
	int s,n;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> s;
		cout << "case " << i+1 << ":\n";
		for(int k=0; k<10; k++){
			s = s*s;
			s /= 100;
			s %= 10000;
			cout << s << endl;
		}
	}
}

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+1<<":"<<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<=5;i++){
                    ans.push_back(t[i]);
                }
                cout<<stoi(ans)<<endl;
            in=ans;
        }
    }
}

C++: #include <bits/stdc++.h>

using namespace std;
 
int main()
{
    int n, d;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> d;
        cout << "Case " << i+1 << ':' << endl;
        for (int j = 0; j < 10; j++) {
            d = d*d%100000000/100%10000;
            cout << d << endl;
        }
    }   
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
void serch(int n,int now)
{
    n*=n;
    int random=(n%1000000/100);
    cout<<random<<endl;
    if(now<10)serch(random,now+1);
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int num;
        cin>>num;
        cout<<"Case"<<i<<':'<<endl;
        serch(num,1);
    }
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <cstdlib>
using namespace std;

int MiddleSquareMethod(int s){
	ostringstream oss;
	oss<<setfill('0')<<setw(8)<<s*s;
	return atoi(oss.str().substr(2,4).c_str());
}

int main() {
	int n,s;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>s;
		cout<<"Case "<<i+1<<":"<<endl;
		for(int j=0;j<10;++j){
			s = MiddleSquareMethod(s);
			cout<<s<<endl;
		}
	}
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	for(int i=1;i<=N;i++){
		int s;
		cin >> s;
		cout << "Case " << i << ":" << endl;
		for(int j=0;j<10;j++){
			s *= s;
			stringstream ss;
			ss << s;
			string r = ss.str();
			//cout << r << endl;
			//rª3¢ÌêC^ñÌÍ¢ÂàO
			if(r.size()<3){s = 0;continue;}
			//(n>5)?4:n-2;
			//(n>5)?n-6:0;
			int dig = (r.size()>5)?4:r.size()-2, pos = (r.size()>5)?r.size()-6:0;
			ss.str("");
			ss << r.substr(pos,dig);
			ss >> s;
			cout << s << endl;
		}
	}
}

C++: #include<iostream>
#include<sstream>
#include<string>
#include<cstdio>
using namespace std;
int main(){
long n,m,i,j;
string s;
stringstream ss;
char mm[9];
cin>>n;
for(i=0;i<n;i++){
cin>>m;
cout<<"Case "<<i+1<<endl;
for(j=0;j<10;j++){
sprintf(mm,"%08d",m*m);
s=string(mm);
s=s.substr(2,4);
m=s.find_first_not_of('0');
cout<<s.substr(m)<<endl;
ss.str("");ss.clear();
ss<<s;
ss>>m;
}
}
return 0;
}

C++: #include <iostream>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int n = 4;

void solve(){
	int s; cin >> s;
	for (int i = 0; i < 10; i++){
		string str = to_string(s*s);
		if (str.size() < 8){
			string str2;
			for (int j = 0; j < 8 - str.size(); j++) str2+='0';
			str2 += str;
			str = str2;
		}
		string ret = "0000";
		for (int j = 0; j < 4; j++){
			ret[j] = str[j + 2];
		}
		int ans = stoi(ret);
		cout << ans << endl;
		s = ans;
	}
}

int main(){
	int num; cin >> num;
	for (int i = 0; i < num; i++){
		cout << "Case " << i + 1 << ":" << endl;
		solve();
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int main() {
	int N;
	cin >> N;
	REP(n, N) {
		printf("Case %d:\n", n + 1);
		int s;
		cin >> s;
		REP(i, 10) {
			s = (s * s) / 100 % 10000;
			cout << s << endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x;
	cin>>n;
	for(int times=0;times<n;times++){
		cout<<"Case "<<times+1<<':'<<endl;
		cin>>x;
		for(int i=0;i<10;i++){
			x=x*x%1000000/100;
			cout<<x<<endl;
		}
	}
}

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

int main() {
    int d;
    cin >> d;
    for (int i = 1; i <= d; i++) {
        int n;
        cin >> n;
        cout << "Case " << i << endl;
        for (int j = 0; j < 10; j++) {
            n *= n;
            n /= 100;
            n %= 10000;
            cout << n << endl;
        }
    }
    return 0;
}

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

int main(void){
	int n,m;
	cin>>m;
	for(int i=1;i<=m;i++){
		cin>>n;
		cout<<"Case "<<i<<":"<<endl;
		for(int j=0;j<10;j++){
			n=n*n;
			n=((n%1000000)/100);
			cout<<n<<endl;
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

int parse(string a){
	int s=0;
	for(char b:a){
		s*=10;
		s+=b-48;
	}
	return s;
	}
int middle(int a){
	a*=a;
string b=to_string(a);
int o=b.length();
for(int c=0;c<8-o;c++)b="0"+b;
string c="    ";
for(int f=0;f<4;f++)c[f]=b[f+2];
return parse(c);
}
int main(){
	int k=0;
int a;
while(cin>>a){
	k++;
	printf("Case %d:\n",k);
	for(int p=0;p<10;p++){
		a=middle(a);
		printf("%d\n",a);
	}
}
}

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

int rand (int a){
	return a=a*a/100-a*a/1000000*10000;
}

int main(){
	int d,l;
	
	cin>>d;
	for(int i=1;i<=d;i++){
		cin>>l;
		cout<<"Case "<<i<<":"<<endl;
		for(int j=0;j<10;j++){
			l=rand(l);
			cout<<l<<endl;
		}
	}
}

C++: #include <iostream>

class Rand {
public:
	Rand(const int &in = 123) :init{ in } {};
	int operator()() {
		return init = next(init);
	}
private:
	int init;
	int next(const int &i) const {
		return (i * i) / 100 % 10000;
	}
};

int main() {
	int n;
	std::cin >> n;
	for (auto c = 1; c <= n; ++c) {
		int init;
		std::cin >> init;
		Rand rand(init);
		std::cout << "Case " << c << ":\n";
		for (auto i = 0; i < 10; ++i) {
			std::cout << rand() << '\n';
		}
	}
	return 0;
}

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

int main(){
	int n,s;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> s;
		cout << "Case " << i + 1 << ":" << endl;
		for(int j = 0;j < 10;j++){
			s = (s * s / 100) % 10000;
			cout << s << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int n, num;
	
	int a[10];
	
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> num;
		a[0] = (num * num / 100) % 10000;
		for(int j = 1; j < 10; j++){
			a[j] = (a[j - 1] * a[j - 1] / 100) % 10000;
		}
		printf("Case %d:\n", i + 1);
		for(int j = 0; j < 10; j++){
			printf("%d\n", a[j]);
		}
	}
	return 0;
}