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>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    int n; cin >> n;

    rep(k,n)
    {
        int r;
        cout << "Case " << k+1 << ":" << endl;
        cin >> r;

        REP(10)
        {
            r = ((r * r) %(1000*1000))/100;
            cout << r << endl;
        }

    }

    return 0;
}

C++: #include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cout << "Case " << i << ":" << endl;
        int s;
        cin >> s;
        for(int j = 0; j < 10; j++) {
            s = s * s;
            string t(8, '0');
            for(int k = 7; s > 0; k--) {
                t[k] = '0' + (s % 10);
                s /= 10;
            }


            for(int k = 2; k < 6; k++) 
                s = s * 10 + (t[k] - '0');
            
            cout << s << endl;

        }
    }
}

C++: #include <iostream>

using namespace std;

typedef long long ll;

int main(){
	ll n, s, ans;
	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;
			s %= 1000000;
			s /= 100;
			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<<" "<<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<stdio.h>
int main(){
int N,x,c=0,x1=0;
scanf("%d",&N);
for(int i=0;i<N;i++)
{
scanf("%d",&x);
int ii=i+1;
printf("Case %d:\n",ii);
for(int j=0;j<10;j++)
{
x=x*x;
x1=x;c=1;

while((x1/10)>0){
x1=x1/10;c++;
//printf("%d",x1);
}
if(c<=2)x=0;
else if(c==3)x=x/100;
else if(c==4)x=x/100;
else if(c==5)x=x/100;
else if(c==6)x=x/100;
else if(c==7){x=x%1000000;x=x/100;}
else if(c==8){x=x%1000000;x=x/100;}
printf("%d\n",x);
}
}
return 0;

}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	for(int z=0;z<a;z++){
		long long n;
		cin>>n;
		cout<<"Case "<<z+1<<":"<<endl;
		for(int j=0;j<10;j++){
			n=n*n;
			string a=to_string(n);
			int b=a.length();
			b=8-b;
			string t;
			for(int i=0;i<b;i++)
				t+="0";
			t+=a;
			string c=t.substr(2,4);
			n=stoi(c);
			cout<<n<<endl;
		}
	}
}

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

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

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

string to_string(int n)
{
	ostringstream oss;
	oss<<n;
	string res=oss.str();
	res=string(8-res.size(),'0')+res;
	return res;
}

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		int s;
		cin>>s;
		printf("Case %d:\n",i+1);
		rep(j,10){
			string t=to_string(s*s);
			s=atoi(t.substr(2,4).c_str());
			cout<<s<<endl;
		}
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

  int num;
  int s;

  int rand;

  
  cin >> num;

  for(int i=0;i<num;i++) {
    
    cin >> s;

    cout << "Case " << i+1 << endl;

    rand=s;

    for(int j=0;j<10;j++) {

      rand=rand*rand;

      if(rand>=1000000) rand%=1000000;

      rand/=100;

      cout << rand << endl;

    }

  }

  return 0;

}

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

int main(void){
  int n;
  cin >> n;
  for(int t = 0; t < n; t++){
    int s;
    cin >> s;
    cout << "Case " << t + 1 << ":" << endl;
    for(int i = 0; i < 10; i++){
      s *= s;
      string str = to_string(s);
      if(str.size() < 8){
        int c = 8 - str.size();
        for(int j = 0; j < c; j++) str.insert(str.begin(), '0');
      }
      s = stoi(string(str, 2, 4));
      cout << s << endl;
    }
  }
}

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

int main(){
	int n;
	int s;
	cin >> n;

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

}

C++: #include<stdio.h>
int main()
{
	int x=0,n,s,i;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&s);
		printf("Case %d:\n",++x);
		for(i=0;i<10;++i)
			printf("%d\n",(s= (s*s)/100%10000));
	}
	return 0;
}

C++: #include <iostream>
#include <queue>

using namespace std;

int main()
{
  int n;
  int s;
  int x = 1;
  queue<int> qu;

  cin >> n;

  while (n--){
    cout << "Case " << x++ << ":" << endl;
    cin >> s;
    for (int i = 0; i < 10; i++){
      s = s * s;
      int t = 10000000;
      for (int cnt = 0; cnt < 8; cnt++){
        qu.push(s / t);
        s %= t;
        t /= 10;
      }
      s = 0;
      t = 1000;
      for (int cnt = 0; cnt < 8; cnt++){
        if (cnt >= 2 && cnt <= 5){
          s += qu.front() * t;
          t /= 10;
        }
        qu.pop();
      }
      cout << s << endl;
    }
  }

  return (0);
}

C++: #include <iostream>

using namespace std;

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

int main()
{
	solve();
	return(0);
}