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<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>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <typeinfo>
#include <iomanip>
#include <sstream>
using namespace std;
int main(){
	int d,cnt;
	long long s,y;
	string str,ans="",x="";
	cin>>d;
	for(int i=1;i<=d;i++){
		cin>>s;
		cout<<"Case "<<i<<":"<<endl;
		for(int o=1;o<=10;o++){
			y=s*s;
			str=to_string(y);
			if(str.size()!=8){
				int num=8-str.size();
				for(int p=0;p<num;p++){
					ans+='0';
				}
				ans+=str;
			}else{
				ans=str;
			}
			if(ans.size()%2==0){
				cnt=ans.size()/2-2;
			}else{
				cnt=ans.size()/2-3;
			}
			for(int k=cnt;k<cnt+4;k++){
				x+=ans[k];
			}
			cout<<stoi(x)<<endl;
			s=stoi(x);
			ans="";
			x="";
		}
	}
	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>
using namespace std;

int jyo(int);

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

int jyo(int n){
  n*=n;
  n-=(n/10000000)*10000000;
  n-=(n/1000000)*1000000;
  return n;
}

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 <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main(){
	int d,cnt;
	long long s,y;
	string str,ans="",x="";
	cin>>d;
	for(int i=1;i<=d;i++){
		cin>>s;
		cout<<"Case "<<i<<":"<<endl;
		for(int o=1;o<=10;o++){
			y=s*s;
			str=std::to_string(y);
			if(str.size()!=8){
				int num=8-str.size();
				for(int p=0;p<num;p++){
					ans+='0';
				}
				ans+=str;
			}else{
				ans=str;
			}
			if(ans.size()%2==0){
				cnt=ans.size()/2-2;
			}else{
				cnt=ans.size()/2-3;
			}
			for(int k=cnt;k<cnt+4;k++){
				x+=ans[k];
			}
			s=stoi(x);
			cout<<s<<endl;
			ans="";
			x="";
		}
	}
	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>
#include <stdio.h>
using namespace std;
int main(){
	int n;
	long s;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
		cout<<"Case "<<i<<":"<<endl;
		for(int j=0;j<10;j++){
			s = s*s;
			s /= 100;
			if(s>=10000) s = s%10000;
			cout<<s<<endl;
		}
	}

	return 0;
}

C++: main(i,j,n,s){
	for(scanf("%d",&n);i<=n;i++){
		scanf("%d",&s);
		printf("Case %d:\n",i);
		for(j=0;j<10;j++)	printf("%d\n",s=(s*s)/100%10000);
	}
	exit(0);
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<queue>
#include<set>

using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

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

C++: #include<bits/stdc++.h>
using namespace std;
void serch(int n,int now)
{
    n=n%1000000/100;
    cout<<n<<endl;
    if(now<10)serch(n*n,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*num,1);
    }
}

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>
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 = (s * s / 100) % 10000;
            cout << s << endl;
        }
    }
}

C++: #include <sstream>
#include <iostream>
#include <cstdio>


using namespace std;

int dataset,aiju;

int main(int argc,char **argv){
  cin >> dataset;
  for(int rupu=0;rupu<dataset;rupu++)
    {
      printf("Case %d:",++aiju); cout << endl;
      int s;
      cin >> s;
      for(int itiToJuu=0;itiToJuu<10;itiToJuu++)
	{
	  s = s * s;
	  stringstream ss;
	  ss << s;
	  string sutoring;
	  ss >> sutoring;

	  s = 0;
	  for(int aaa=(int)sutoring.size()-6;aaa<(int)sutoring.size()-2;aaa++)
	    {
	      if( aaa < 0 )
		{
		  continue;
		}
	      else 
		{
		  s = s * 10;
		  s = s + sutoring[aaa] - '0';
		  cout << sutoring[aaa];
		}
	    }
	  cout << 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 << ':' << endl;
    for (int i=0; i<10; i++)
    {
      rand = rand*rand;
      rand = rand/100 - (rand/1000000)*10000;
      cout << rand << endl;
    }
  }
}