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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n;
  cin>>n;
  REP(i,n){
    printf("Case %d:\n",i+1);
    int s;
    cin>>s;
    REP(i,10){
      s *= s;
      s = (int)(s/1e5)%10*1e3 + (int)(s/1e4)%10*1e2 + (int)(s/1e3)%10*10 +(int)(s/1e2)%10;
      printf("%d\n",s);
    }
  }

  return 0;
}

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

typedef unsigned long long ull;

int main(){
  ull s;
  int T;
  cin >> T;
  for(int cs = 1 ; cs <= T ; cs++){
    ull ans[10];
    cin >> s;
    
    ull tmp = s*s;
    tmp /= 100;
    tmp %= 10000;
    
    ans[0] = tmp;
    
    for(int i = 1 ; i < 10 ; i++){
      ans[i] = ans[i-1]*ans[i-1];
      ans[i] /= 100;
      ans[i] %= 10000;
    }
    
    printf("Case %d:\n", cs);
    for(int i = 0 ; i < 10 ; i++){
      cout << ans[i] << endl;
    }
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

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

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

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<bits/stdc++.h>
using namespace std;

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main() {

  int n;
  cin>> n;
  for(int num=0; num<n; num++) {
    int s;
    cin>> s;
    int rand_num=s;
    printf("Case %d:\n", num+1); 
    for(int i=0; i<10; i++) {
      rand_num*=rand_num;
      rand_num%=1000000;
      rand_num/=100;
      printf("%d\n",rand_num);
    }
  }
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;
string i2s(int num){
  stringstream ss;
  string str;
  ss << num;
  ss >> str;
  return str;
}
int main(){
  int n;
  cin >> n;
  for(int k = 1 ; k <= n ; k++ ){
    int num;
    cin >> num;
    cout << "Case " << k << ":" << endl;
    for(int i = 0 ; i < 10 ; i++ ){
      string tmp = i2s(pow(num,2));
      string str="";
      for(int i = 0 ; i < 8 - tmp.size() ; i++){
	str+='0';
      }
      str+=tmp;
      str = str.substr(2,4);

      cout << atoi(str.c_str()) << endl;

      num = atoi(str.c_str()); 
    }
  }
  return 0;
}

C++: #include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
using namespace std;

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

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n; cin>>n;
  REP(c,n){
    int s; cin>>s;
    printf("Case %d:\n",c+1);
    REP(i,10){
      char buff[16];
      sprintf(buff,"%08d",s*s);
      buff[6] = '\0';
      sscanf(buff+2,"%d",&s);
      printf("%d\n",s);
    }
  }
  return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

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

	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 <vector>
#include <sstream>
using namespace std;

int next(int x) {
    return ((x * x) / 100) % 10000;
}

int main() {
    int n, s;
    cin >> n;
    for (int i=1; i<=n; ++i) {
        cout << "Case " << i << ":" << endl;
        cin >> s;
        for (int j=0; j<10; ++j) {
            s = next(s);
            cout << s << endl;
        }
    }
    return 0;
}