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
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//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 SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e9;

struct edge{int to,cost;};
typedef pair<int,int> P;//firstは最短距離,secondは頂点番号


int main(){
	int n;cin>>n;
	REP(i,n){
		
		int x;
		cin>>x;
		cout<<"Case "<<i+1<<":"<<endl;
		REP(j,10){
			string str=toString(x*x);
			string ans="";
			FOR(k,SZ(str),8)ans+='0';
			ans+=str;
			x=toInt(ans.substr(2,4));
			cout<<x<<endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<sstream>
#include<string>
#include<cstdio>
using namespace std;
int main(){
long n,m,i,j;
string s;
stringstream ss;
string::size_type k;
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);
k=s.find_first_not_of('0');
cout<<s.substr(k)<<endl;
ss.str("");ss.clear();
ss<<s;
ss>>m;
}
}
return 0;
}

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

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

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

int main()
{
	int n; std::cin >> n;
	for (int i=0; i<n; i++) {
		int s; std::cin >> s;
		std::cout << "Case " << i+1 << ":" << std::endl;
		for (int j=0; j<10; j++) {
			s *= s;
			std::ostringstream oss;
			oss << std::setw(8) << std::setfill('0') << s;
			s = std::stoi(oss.str().substr(2,4));
			std::cout << s << std::endl;
		}
	}
	
	return 0;
}

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

using namespace std;

template <typename T> string toString(const T& t) {
    ostringstream os; os << t; return os.str();
}

void solve(int s) {
    string w;
    for (int i = 0; i < 10; i++) {
        w = toString(s * s);
        while (w.size() != 8) w = "0" + w;
        w = w.substr(2, 4);
        s = atoi(w.c_str());
        cout << s << endl;
    }
}

int main(void) {
    int d, s;
    cin >> d;
    for (int i = 0; i < d; i++) {
        cin >> s;
        cout << "Case " << i + 1 << ":\n";
        solve(s);
    }

    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int keta(int n) {
	int k = 0;
	for (int i = n; i > 0; i /= 10)++k;
	return k;
}

string re2(char c, int n) {
	string ret; ret.assign(n, c);
	return ret;
}

int re(int n) {
	int NxN = n * n;
	string s = re2('0', 8 - keta(NxN)) + to_string(NxN);
	string r = s.substr(2, 4);
	return stoi(r);
}

int main() {
	int n; cin >> n;
	rep(i, n) {
		int x; cin >> x;
		cout << "Case " << i + 1 << ":\n";
		rep(loop, 10) {
			x = re(x);
			Cout(x);
		}
	}
}

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

using namespace std;

int const RSIZE = 4;

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

int toInt(string s) {
  stringstream ss(s);
  int x; ss>>x;
  return x;
}

int change(int n) {
  
  int res = 0;
  int get = n*n;
  string s = toStr(get); int const ssize = s.size();
  string t;
  for(int i=0; i<2*RSIZE; i++) {
    if(ssize-1-i>=0) {
      t = s[ssize-1-i] + t;
    }
    else {
      t = '0' + t;
    }
  }
  
  string pre;
  for(int i=2; i<6; i++) {
    pre += t[i];
  }
  
  return toInt(pre);
}

int main() {
  int Tc; cin >> Tc;
  
  for(int T = 1; T <= Tc; T++) {
    cout << "Case " << T << ":" << endl;
    
    int N; cin >> N;
    
    int n = N;
    for(int i=0; i<10; i++) {
      n = change(n);
      cout << n << endl;
    }
  }
  
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    int in;
    cin>>in;
    cout<<"Case"<<" "<<i<<":"<<endl;
    for(int j=0;j<10;j++){
      in*=in;
      in=in%1000000;
      in/=100;
      cout<<in<<endl;
    }


  }
}

C++: 
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

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

	rep(i, n) {
		ll num;
		cin >> num;

		cout << "Case " << i + 1 << ":" << endl;
		rep(j, 10) {
			num = num*num;
			string str = to_string(num);
			while (str.size() < 8)
				str = "0" + str;

			str = str.substr(2,4);
			num = stoll(str);
			cout << num << endl;
		}
	}
	return 0;
}

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

int main(){
  int i,j,n,c=1,s;
  cin >> n;
  for(int t=0;t<n;t++){
    cin >> s;
    cout << "Case " << c++ << ":" << endl;
    for(i=0;i<10;i++){
      s *= s;
      while(s >= 1000000) s -= 1000000;
      s /= 100;
      cout << s << endl;
    }

  }
  return 0;
}