Go: package main

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

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 <iostream>
using namespace std;

int main(){
    int ans2[10],ans1[10];
    int n,f,e,cnt;
    bool sj,fj,judge;
    cin >> n;
    while(n--){
        cin >> f >> e;
        cnt = 1;
        sj = false;
        fj = false;
        judge = false;
        int sta = f;
        ans1[0] = sta;
        ans2[0] = sta;
        while(1){
            if(sta == e) break;
            if(f == e){
                judge = true;
                break;
            }
            if(sta == 9 && !sj){
                sta = 5;
                sj = true;
            }
            else if(sta == 0 && sj) sj = false;
            else if(sj) sta--;
            else if(!sj) sta++;
            ans1[cnt] = sta;
            
            if(f == 0 && !fj) fj = true;
            else if(sta == 9 && !fj){
                fj = false;
                f = 5;
            }
            else if(!fj) f--;
            else if(fj) f++;
            ans2[cnt] = f;
            cnt++;
        }
        if(judge){
            for(int i=0;i<cnt-1;i++) cout << ans2[i] << " ";
            cout << ans2[cnt-1] << endl;
        }
        else {
            for(int i=0;i<cnt-1;i++) cout << ans1[i] << " ";
            cout << ans1[cnt-1] << endl;
        }
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
	int n, src, dir = 1, dst, spc;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> src >> dst;
		spc = 0;
		if(src<dst || (src>dst && src>=6))dir = 1;
		else dir = -1;
		int j=0;
		do{
			if(src+j>9){
				j=5-src;
				dir = -1;
			}
			if(spc++ != 0)cout << " ";
			cout << src+j;
		}while(src+(dir>0 ? j++ : j--)!=dst);
		if(i!=n-1)cout << endl;
	}
	return 0;
}

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

using namespace std;
string bus_stop = "0123456789543210123456789543210";

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		char s, g;
		cin >> s >> g;
		string ans1, ans2;
		bool flag = false;
		int pos = 0;
		for(int i = 0; i < bus_stop.size(); ++i)
		{
			if(!flag && bus_stop[i] == s)
			{
				flag = true;
				pos = i;
			}
			if(flag)
			{
				ans1 += bus_stop[i];
				if(bus_stop[i] == g)
				{
					break;
				}
			}
		}
		flag = false;
		for(int i = pos + 1; i < bus_stop.size(); ++i)
		{
			if(bus_stop[i] == s)
			{
				flag = true;
			}
			if(flag)
			{
				ans2 += bus_stop[i];
				if(bus_stop[i] == g)
				{
					break;
				}
			}
		}
		if(ans1.size() < ans2.size())
		{
			cout << ans1[0];
			for(int i = 1; i < ans1.size(); ++i)
			{
				cout << " " << ans1[i];
			}
			cout << endl;
		}
		else
		{
			cout << ans2[0];
			for(int i = 1; i < ans2.size(); ++i)
			{
				cout << " " << ans2[i];
			}
			cout << endl;
		}
	}
}

int main()
{
	solve();
	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>
using namespace std;
int a[]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
int n;
main()
{
	cin>>n;
	for(;n--;)
	{
		int s,t;cin>>s>>t;
		int cnt=0,i=0;
		while(a[i]!=s)i++;
		while(a[(i+cnt)%15]!=t)cnt++;
		int cnta=1e5,j=i+1;
		while(j<15&&a[j]!=s)j++;
		if(j<15)
		{
			cnta=0;
			while(a[(j+cnta)%15]!=t)cnta++;
		}
		if(cnt<cnta)
		{
			for(int k=0;k<=cnt;k++)cout<<a[(i+k)%15]<<(k==cnt?"\n":" ");
		}
		else
		{
			for(int k=0;k<=cnta;k++)cout<<a[(j+k)%15]<<(k==cnta?"\n":" ");
		}
	}
}

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

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

using namespace std;

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

	int d[25] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9};

	rep(i,n)
	{
		int a,b;
		cin >> a >> b;

		vector<int> v,v2;
		
		bool flag = false;
		for(int j=0;j<26;j++)
		{
			if(d[j] == a && !flag)
			{
				flag = true;
			}
			else if(d[j] == a && flag)
			{
				v.clear();
			}

			if(flag) v.push_back(d[j]);
			
			if(flag && d[j] == b)
			{
				flag = false;
				break;
			}
		}

		bool first = true;
		rep(j,v.size())
		{
			if(first)
			{
				first = false;
			}
			else cout << " ";
			cout << v[j];
		}
		cout << endl;
	}
	return 0;
}

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

int busLine[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1 };
const int SIZE = sizeof(busLine) / sizeof(int);

int main()
{
	int n;
	while( cin >> n ){
		for( int i = 0; i < n; ++i ){
			int start, end;
			cin >> start >> end;

			int step = 0;
			int index = 0;
			int memo[ 10 ];
			bool bFoundStart = false;
			while( 1 ){
				if( busLine[ index ] == start ){
					bFoundStart = true;
					step = 0;
					memo[ step ] = busLine[ index ];
					++index;
					continue;
				}
				++step;
				memo[ step ] = busLine[ index ];
				if( bFoundStart && busLine[ index ] == end ){
					break;
				}
				++index;
				index %= SIZE;
			}

			bool bFirst = true;
			for( int j = 0; j <= step; ++j ){
				if( bFirst ){
					bFirst = false;
				}else{
					cout << " ";
				}
				cout << memo[ j ];
			}
			cout << endl;
		}
	}
	return 0;
}

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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

void upto(vector<int>& v, int f, int t)
{
  for (int i = f; i <= t; i++) v.push_back(i);
}
void downto(vector<int>& v, int f, int t)
{
  for (int i = f; i >= t; i--) v.push_back(i);
}

int main()
{
  rep(i, in()){
    int f, t;
    f = in();
    t = in();
    vector<int> way;
    if (f < t) upto(way, f, t);
    else if (f <= 5) downto(way, f, t);
    else if (t <= 5) upto(way, f, 9), downto(way, 5, t);
    else upto(way, f, 9), downto(way, 5, 0), upto(way, 1, t);
    show(way, ' ');
  }
  return 0;
}