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>

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

using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	
	rep(i,n)
	{
		ll a;
		cin >> a;
	
		cout << "Case " << i+1 << ":" << endl;
		rep(j,10)
		{
			a *= a;
			a /= 100;
			ll b = a/10000;
			b *= 10000;
			a -= b;
			cout << a << endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int n,s;
	cin>>n;
	rep(i,0,n){
		cin>>s;
		o("Case "<<i+1<<":");
		rep(j,0,10){
			s=s*s/100;
			s%=10000;
			printf("%d\n",s);
		}
	}
}

C++: #include <stdio.h>
int main(){
	int s=0,n,x,i,e[8]={};
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		printf("Case %d:\n",i);
		for(int j=0;j<10;j++){
			for(int q=0;q<8;q++){
				e[q]=0;
			}
			int g=7;
			int y=x*x;
			while(y){
				e[g]=y%10;
				y/=10;
				g--;
			}
			for(int k=2;k<6;k++){
				if(e[k]==0 & s==0){
				}else{
					printf("%d",e[k]);
				s=1;}
			}s=0;
			printf("\n");
			x=e[2]*1000+e[3]*100+e[4]*10+e[5];
		}
	}
return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,s;
	cin>>n;
	for(int u=0;u<n;u++){
		cin>>s;
		cout<<"Case "<<u+1<<":"<<endl;
		for(int o=0;o<10;o++){
			s=s*s%1000000/100;
			cout<<s<<endl;
		}
	}
	return 0;
}

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 <stdio.h>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;



int main(){

	int d,s;

	scanf("%d",&d);

	for(int i=0; i < d; i++){
		scanf("%d",&s);

		printf("Case %d:\n",i+1);
		for(int k=0; k < 10; k++){
			s = s*s;
			s /= 100;
			s %= 10000;
			printf("%d\n",s);
		}

	}

    return 0;
}

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;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)

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

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int d;
  cin >> d;
  for (int i = 0; i < d; i++) {
    cout << "Case " << i + 1 << ":" << endl;
    string s;
    cin >> s;
    for (int j = 0; j < 10; j++) {
      string t = to_string(stoi(s) * stoi(s));
      while (int(t.size()) < 8) t = "0" + t;
      s = t.substr(2, 4);
      cout << stoi(s) << endl;
    }
  }

  return 0;
}

C++: #include <bits/stdc++.h>
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) {
      s = pow(s, 2) / 100;
      if(s >= 10000) s -= s / 10000 * 10000;
      cout << s << endl;
    }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

char buf[50];
int main() {
	ll s;
	int d; cin >> d;
	rep(j, d) {
		cin >> s;
		printf("Case %d:\n", j + 1);
		rep(i, 10) {
			s *= s;
			sprintf(buf, "%08lld", s);
			string ans(buf);
			cout << (s = stoi(ans.substr(2, 4))) << endl;
		}
	}
}

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

using namespace std;

int cont = 0;

void Smethod(int a)
{
	if(cont == 10) return;
	int y[8];
	for(int i = 0; i < 8; i++)
	{
		y[i] = a % 10;
		a = floor(a / 10);
	}
	cout<< y[5] << y[4] << y[3] << y[2] << endl;
	int b = y[5]*1000 + y[4]*100 + y[3]*10 + y[2];
	cont++;
	Smethod(b*b);
}

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

	for(int i = 1; i <= n; i++)
	{
		cin >> a;
		printf("Case %d:\n",i);
		Smethod(a*a);
		cont = 0;
	}
}

C++: #include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	unsigned int 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;
			unsigned int a = s / 10000;
			a *= 10000;
			s -= a;

			cout << s << endl;
		}
	}
	

	return 0;
}

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

int main() {

  int q;
  cin >> q;

  for(int i=0;i<q;i++) {
    
    int b;
    cin >> b;
    cout <<"Case "<<i+1<<":"<<endl;
    for(int j=0;j<10;j++) {
      int a[8] = {};  
      b *= b;
      for(int k=7;k>=0;k--) {
	a[k] = b % 10;
	b /= 10;
      }
      int t = 1;
      b = 0;
      for(int k=5;k>=2;k--) {
	b += a[k]*t;
	t*=10;
      }
      cout << b << endl;
    }


  }

  return 0;
}

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

int main()
{
  int n;
  cin >> n;
  for (int dataset=0; dataset<n; dataset++)
  {
    int rand;
    cin >> rand;
    cout << "Case " << dataset+1 << ':' << endl;
    for (int i=0; i<10; i++)
    {
      rand = rand*rand;
      rand = rand/100 - (rand/1000000)*10000;
      cout << rand << endl;
    }
  }
}

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

string itos(int x){
  stringstream ss;
  ss << x;
  return ss.str();
}

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

  for(int SET = 1; SET <= T; SET++){
    printf("Case %d:\n", SET);

    int n;
    cin >> n;

    for(int i = 0; i < 10; i++){
      n *= n;
      string s = itos(n);

      while(s.length() != 8){
        s = "0" + s;
      }

      string ts = "";

      for(int i = 2; i <= 5; i++){
        ts += s[i];
      }

      n = atoi(ts.c_str());
      cout << n << endl;
    }
  }
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	REP(k,N){
		cout << "Case " << k+1 << ":" << endl;
		int S=in();
		REP(i,10){
			int V=S*S;
			V %= 1000000;
			S = V/100;
			out(S);
		}
	}
	return 0;
}