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 n,s;
	cin>>n;
	for(int i=0;i<n;i++){
		cout<<"Case "<<i+1<<':'<<endl;
		cin>>s;
		for(int j=0;j<10;j++){
			s=s*s/100%10000;
			cout<<s<<endl;
		}
	}
	return 0;
}

C++: #include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n;
	scanf("%d", &n);
	rep(i, n){
		printf("Case %d:\n", i+1);
		int s;
		scanf("%d", &s);
		rep(j, 10){
			char str[16];
			sprintf(str, "%08d", s*s);
			str[6] = '\0';
			s = atoi(str + 2);
			printf("%d\n", s);
		}
	}
	
	return 0;
}

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

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;
        }
    }
    cout<<endl;
}

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

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

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



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

    return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int n;
    long s;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        cout << "Case " << i + 1 << ":\n" ;

        long long tmp;
        for (int j = 0; j < 10; j++) {
            s *= s;
            s /= 100;
            s %= 10000;
            
            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++: // 2011/01/11 Tazoe

#include <iostream>
using namespace std;

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

	for(int x=1; x<=n; x++){
		int s;
		cin >> s;

		cout << "Case " << x << ":" << endl;

		for(int i=0; i<10; i++){
			s = s*s;
			s = (s/100)%10000;
			cout << s << endl;
		}
	}

	return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  rep(i, n) {
    cout << "Case " << i + 1 << endl;
    int x;
    cin >> x;
    rep(j, 10) {
      stringstream ss;
      ss << setfill('0') << setw(8) << x * x;
      string s;
      ss >> s;
      ss.clear();
      ss << s.substr(2, 4);
      ss >> x;
      cout << x << endl;
    }
  }
}

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

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

    for (int x = 1; x <= count; x++) {
        long long  n;
        cin >> n;
        stringstream ss;
        ss << n;
        cout << "Case " << x << ":" << endl;
        for (int i = 0; i < 10; i++) {
            n *= n;
            n /= 100;
            int j = 0;
            int k = 1;
            int tmp = 0;
            while (j < 4) {
                tmp += (n % 10) * k;
                k *= 10;
                n /= 10;
                j++;
            }
            n =  tmp;
            cout << tmp << endl;
        }
    }

    return 0;
}