#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int p,q;
        cin>>p>>q;
        cout<<p<<'/'<<q<<" = ";
        cout<<p/q;
        queue<char> res;
        while(p%q!=0)
        {
            cout<<"+1/";
            p=p%q;
            swap(p,q);
            if(p%q)
            {
                cout<<'{';
                res.push('}');
            }
            cout<<p/q;
        }
        while(!res.empty())
        {
            cout<<res.front();
            res.pop();
        }
        cout<<endl;
    }
    return 0;
}

//103/24=4   103%24=7
//24/7=3     24%7=3
//7/3=2      7%3=1
//3/1=3