Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		input := strings.Split(scanner.Text(), " ")
		s, _ := strconv.Atoi(input[0])
		e, _ := strconv.Atoi(input[1])
		a := make([]int, 0)
		if s <= 5 {
			if s > e {
				for j := s; j > e-1; j-- {
					a = append(a, j)
				}
			} else {
				for j := s; j < e+1; j++ {
					a = append(a, j)
				}
			}
		} else if s < e {
			for j := s; j < 10; j++ {
				a = append(a, j)
			}
		} else {
			for j := s; j < 10; j++ {
				a = append(a, j)
			}
			if e <= 5 {
				for j := 5; j > e-1; j-- {
					a = append(a, j)
				}
			} else {
				for j := 5; j > 0; j-- {
					a = append(a, j)
				}
				for j := 0; j < e+1; j++ {
					a = append(a, j)
				}
			}
		}
		for i, v := range a {
			if i != len(a)-1 {
				fmt.Printf("%d ", v)
			} else {
				fmt.Println(v)
			}
		}
	}
}

C++: #include <cstdio>
int main()
{
int s,t,d,n;
scanf("%d",&n);
while(n--){
scanf("%d %d",&s,&t);
d=(t<s&&s<6)?-1:1;
while(t!=s){
printf("%d ",s);
s+=d;
if(s==10){
d=-1;
s=5;
}else if(s==0){
d=1;
}
}
printf("%d\n",t);
}	
return 0;
}

C++: #include <iostream>

int main()
{
	int n; std::cin >> n;
	for (int i=0; i<n; i++) {
		int s, t;
		std::cin >> s >> t;
		std::cout << s;
		if (0 <= s && s <= 5) {
			if (0 <= t && t <= 5) {
				if (s<t) {
					for (int k=s+1; k<=t; k++) std::cout << " " << k;
				} else {
					for (int k=s-1; k>=t; k--) std::cout << " " << k;
				}
			}
			else { // t = 6,7,8,9
				for (int k=s+1; k<=t; k++) std::cout << " " << k;
				//for (int k=s+1; k<=5; k++) std::cout << " " << k;
				//if (t<=7) {
				//	for (int k=6; k<=t; k++) std::cout << " " << k;
				//} else {
				//	for (int k=9; k>=t; k--) std::cout << " " << k;
				//}
			}
		}
		else { // s = 6,7,8,9
			if (0 <= t && t <= 5) {
				//if (s <= 7) {
				//	for (int k=s-1; k>=t; k--) std::cout << " " << k;
				//} else {
					for (int k=s+1; k<=9; k++) std::cout << " " << k;
					for (int k=5; k>=t; k--) std::cout << " " << k;
				//}
			}
			else { // t = 6,7,8,9
				if (s<t) {
					for (int k=s+1; k<=t; k++) std::cout << " " << k;
				} else {
				//	for (int k=s-1; k>=t; k--) std::cout << " " << k;
					for (int k=s+1; k<=9; k++) std::cout << " " << k;
					for (int k=5; k>=0; k--) std::cout << " " << k;
					for (int k=1; k<=5; k++) std::cout << " " << k;
					for (int k=6; k<=t; k++) std::cout << " " << k;
				}
				
			}
		}
		std::cout << std::endl;
	}
	
	return 0;
}

C++: /*
 *	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0140
 *	1-5までの停留所1-5,10-15に行先べつに分割
 */

#include <iostream>
using namespace std;

int main() {
	int hmData;		//	how many Data?
	cin >> hmData;
	
	for(int i = 0;i < hmData;i++)
	{
		int Dep,Dest;	//Dep = Departure Place,Dest = Destination Place
		cin >> Dep;
		cin >> Dest;
		
		if(Dep <= 5 && Dest <= 5)
		{
			if(Dep > Dest)
			{
				Dep = 15 - Dep;
				Dest = 15 - Dest;
			}
		}else{
			if(Dep > Dest)
			{
				Dest = 15 - Dest;
			}
		}
		
		while(Dep <= Dest)
		{
			if(Dep > 9){
				cout << 15 - Dep;
			}else{
				cout << Dep;
			}
			Dep++;
		}
		cout << "\n";
	}
	return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int main() {
    int N;
    cin >> N;
    for (;N--;) {
        int src, dst;
        cin >> src >> dst;

        if (src < dst) {
            cout << src;
            for (int j = src+1; j <= dst; ++j) {
                cout << ' ' << j;
            }
            cout << endl;
        } else {
            cout << src;
            if (src <= 5) {
                for (int j = src-1; j >= dst; --j) {
                    cout << ' ' << j;
                }
            } else {
                for (int j = src+1; j <= min(dst, 9); ++j) {
                    cout << ' ' << j;
                }
                if (dst <= 5) {
                    for (int j = 5; j >= dst; --j) {
                        cout << ' ' << j;
                    }
                } else {
                    for (int j = 5; j <= dst; ++j) {
                        cout << ' ' << j;
                    }
                }
            }
            cout << endl;
        }

    }

    return 0;
}

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

int main() {
	int hmData;		//	how many Data?
	cin >> hmData;
	
	for(int i = 0;i < hmData;i++)
	{
		int Dep,Dest;	//Dep = Departure Place,Dest = Destination Place
		cin >> Dep;
		cin >> Dest;
		
		if(Dep <= 5 && Dest <= 5)
		{
			if(Dep > Dest)
			{
				Dep = 15 - Dep;
				Dest = 15 - Dest;
			}
		}else{
			if(Dep > Dest)
			{
				Dest = 15 - Dest;
			}
		}
		
		while(Dep <= Dest)
		{
			if(Dep > 9){
				cout << 15 - Dep;
			}else{
				cout << Dep;
			}
			if(Dep != Dest)
				cout << " ";
			Dep++;
		}
		cout << "\n";
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int F = 9;

int main()
{
    int s, g, n; cin >> n;
    REP(n)
    {
        vector<int> ans;
        cin >> s >> g;
        if(s <= 5 && g <= 5)
        {
            if( s < g)for(int j = s;j <= g;j++) ans.push_back(j);

            if(s > g)for(int j = s; j >= g;j--) ans.push_back(j);
        }
        if( s>5 && g <= 5)
        {
            for(int j = s; j<= F;j++) ans.push_back(j);
            for(int j = 5; j >= g;j--)ans.push_back(j);
        }
        if(s <= 5 && g> 5)
            for(int j = s; j<=g;j++) ans.push_back(j);
    
        if(s >5 && g > 5)
        {
            if( s < g)for(int j = s; j<=g;j++) ans.push_back(j);
            if( s > g )
            {
                for(int j = s; j<=F;j++) ans.push_back(j);
                //for(int j = 5; j>=0;j--) ans.push_back(j);
                for(int j = 5;j <=g;j++) ans.push_back(j);
            }
        }

        rep(j,ans.size()){ cout << ans[j]; if(i == ans.size()-1) break; cout << " ";}
        cout << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
long n,s,e,i,j;
cin>>n;
for(j=0;j<n;j++){
cin>>s>>e;
if(s<6){
if(e<6){
if(s<e){cout<<s;for(i=s+1;i<=e;i++)cout<<" "<<i;cout<<endl;}
else{cout<<s;for(i=s-1;i>=e;i--)cout<<" "<<i;cout<<endl;}
}else{
cout<<s;for(i=s+1;i<=e;i++)cout<<" "<<i;cout<<endl;
}
}else{
if(e<6){
cout<<s;
for(i=s+1;i<=9;i++)cout<<" "<<i;
for(i=5;i>=e;i--)cout<<" "<<i;cout<<endl;
}else{
if(s<e){cout<<s;for(i=s+1;i<=e;i++)cout<<" "<<i;cout<<endl;}
else{
cout<<s;
for(i=s+1;i<=9;i++)cout<<" "<<i;
for(i=5;i>=0;i--)cout<<" "<<i;
for(i=1;i<=e;i++)cout<<" "<<i;cout<<endl;
}
}
}
}
return 0;
}