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 ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  rep(i,n){
    int s;
    cin >> s;
    cout << "Case " << to_string(1+i)<<":"<<endl;
    rep(j,10){
      s *= s;
      string str = to_string(s);
      while(str.size() < 8){
        str = "0" + str;
      }
      string next = "";
      for(int i = str.size()/2-2;i < str.size()/2+2;++i){
        next+=str[i];
      }
      s = ston(next,1);
      cout << s << endl;
    }
  }
  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>
#include <map>
#include <algorithm>
#include <bitset>
#include <set>
#include <functional>

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;
typedef long long int lint;

int middle_square(int s) {
	return ((s * s) / 100) % 10000;
}

void AOJ0137(int x)
{
	int s;
	cin >> s;
	cout << "Case " << x << ":" << endl;
	REP(i, 10) {
		cout << (s = middle_square(s)) << endl;
	}
	return;
}

int main()
{
	int d;
	cin >> d;
	REP(i, d) AOJ0137(i + 1);

	return 0;
}

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

int d, s;

int main()
{
    cin >> d;

    for (int i = 0; i < d; i++) {
        cin >> s;

        cout << "Case " << i + 1 << ":" << endl;

        for (int j = 0; j < 10; j++) {
            s = s * s;

            s /= 100;
            s %= 10000;

            cout << s << endl;
        }
    }

    return 0;
}

C++: #include<iostream>
#include<algorithm>

using namespace std;

int num;

string toc(int num){
  string out;
  while(num > 0){
    out += num%10 + '0';
    num /= 10;
  }
  while(out.length() < 8) out += '0';
  reverse(out.begin(),out.end());
  return out;
}

int toi(string in){
  int out = 0;
  int plus = 1;
  for(int i = in.length()-1; i >= 0; i--){
    out += (in[i] - '0') * plus;
    plus *= 10;
  }
  return out;
}
void solve(){
  for(int i = 0; i < 10; i++){
    string sub;
    num = num*num;
    string str = toc(num);
    int flg = 0;
    for(int j = 2; j < 6; j++){
      sub += str[j];
      if(str[j] != '0') flg = 1;
      if(flg) cout << str[j];
      if(!flg && j == 5) cout << str[j];
    }
    cout << endl;
    num = toi(sub);
  }
}

int main(){
  int in;
  cin >> in;
  int rev = 0;
  for(int i = 0; i < in; i++){
    rev++;
    cin >> num;
    cout << "Case " << rev <<":" <<endl;
    solve();
  }
  return 0;
}

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++: #define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

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

double cross(const xy_t &a, const xy_t &b){
	return imag(conj(a) * b);
}

double dot(const xy_t &a, const xy_t &b){
	return real(conj(a) * b);
}

xy_t projection(const line &l, const xy_t &p){
	double t = dot(p - l.first, l.first - l.second) / norm(l.first - l.second);
	return l.first + t * (l.first - l.second);
}

bool intersectSP(const line &l, const xy_t &p){
	return abs(l.first- p) + abs(l.second - p) - abs(l.first - l.second) < EPS;
}

double distanceSP(line s, xy_t p){
	const xy_t r = projection(s, p);
	if(intersectSP(s, r)) return abs(r - p);
	return min(abs(s.first - p), abs(s.second - p));
}

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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	rep(i,n){
		cout<<"Case "<<i+1<<":"<<endl;
		int a;
		cin>>a;
		rep(j,10){
			a*=a;
			a=a%1000000/100;
			cout<<a<<endl;
		}
	}		
}

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

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