using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("1");
WillReturn.Add("50");
}
else if (InputPattern == "Input2") {
WillReturn.Add("1");
WillReturn.Add("96");
}
else if (InputPattern == "Input3") {
WillReturn.Add("3");
WillReturn.Add("240");
WillReturn.Add("480");
WillReturn.Add("1200");
}
else if (InputPattern == "Input4") {
WillReturn.Add("2");
WillReturn.Add("2016");
WillReturn.Add("423");
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
long[] NArr = InputList.Skip(1).Select(pX => long.Parse(pX)).ToArray();
Dictionary<long, long> KoudoGouseiDict = DeriveKoudoGouseiDict();
long[] KoudoGouseiArr = KoudoGouseiDict.Keys.ToArray();
Array.Sort(KoudoGouseiArr);
foreach (long EachA in NArr) {
int ResultInd = ExecNibunhou_LowerOrEqual_Max(EachA, KoudoGouseiArr);
long ResultVal = KoudoGouseiArr[ResultInd];
long YakusuuCnt = KoudoGouseiDict[ResultVal];
Console.WriteLine("{0} {1}", YakusuuCnt, ResultVal);
}
}
// 二分法で、Val以下で最大の値を持つ、添字を返す
static int ExecNibunhou_LowerOrEqual_Max(long pVal, long[] pArr)
{
// 最後の要素がVal以下の特殊ケース
if (pVal >= pArr.Last()) {
return pArr.GetUpperBound(0);
}
// 最初の要素がVal超えの特殊ケース
if (pVal < pArr[0]) {
return -1;
}
int L = 0;
int R = pArr.GetUpperBound(0);
while (L + 1 < R) {
int Mid = (L + R) / 2;
if (pArr[Mid] <= pVal) {
L = Mid;
}
else {
R = Mid;
}
}
return L;
}
// 高度合成数のDictを返す
static Dictionary<long, long> DeriveKoudoGouseiDict()
{
var WillReturn = new Dictionary<long, long>();
WillReturn[1] = 1;
WillReturn[2] = 2;
WillReturn[4] = 3;
WillReturn[6] = 4;
WillReturn[12] = 6;
WillReturn[24] = 8;
WillReturn[36] = 9;
WillReturn[48] = 10;
WillReturn[60] = 12;
WillReturn[120] = 16;
WillReturn[180] = 18;
WillReturn[240] = 20;
WillReturn[360] = 24;
WillReturn[720] = 30;
WillReturn[840] = 32;
WillReturn[1260] = 36;
WillReturn[1680] = 40;
WillReturn[2520] = 48;
WillReturn[5040] = 60;
WillReturn[7560] = 64;
WillReturn[10080] = 72;
WillReturn[15120] = 80;
WillReturn[20160] = 84;
WillReturn[25200] = 90;
WillReturn[27720] = 96;
WillReturn[45360] = 100;
WillReturn[50400] = 108;
WillReturn[55440] = 120;
WillReturn[83160] = 128;
WillReturn[110880] = 144;
WillReturn[166320] = 160;
WillReturn[221760] = 168;
WillReturn[277200] = 180;
WillReturn[332640] = 192;
WillReturn[498960] = 200;
WillReturn[554400] = 216;
WillReturn[665280] = 224;
WillReturn[720720] = 240;
WillReturn[1081080] = 256;
WillReturn[1441440] = 288;
WillReturn[2162160] = 320;
WillReturn[2882880] = 336;
WillReturn[3603600] = 360;
WillReturn[4324320] = 384;
WillReturn[6486480] = 400;
WillReturn[7207200] = 432;
WillReturn[8648640] = 448;
WillReturn[10810800] = 480;
WillReturn[14414400] = 504;
WillReturn[17297280] = 512;
WillReturn[21621600] = 576;
WillReturn[32432400] = 600;
WillReturn[36756720] = 640;
WillReturn[43243200] = 672;
WillReturn[61261200] = 720;
WillReturn[73513440] = 768;
WillReturn[110270160] = 800;
WillReturn[122522400] = 864;
WillReturn[147026880] = 896;
WillReturn[183783600] = 960;
WillReturn[245044800] = 1008;
WillReturn[294053760] = 1024;
WillReturn[367567200] = 1152;
WillReturn[551350800] = 1200;
WillReturn[698377680] = 1280;
WillReturn[735134400] = 1344;
WillReturn[1102701600] = 1440;
WillReturn[1396755360] = 1536;
WillReturn[2095133040] = 1600;
WillReturn[2205403200] = 1680;
WillReturn[2327925600] = 1728;
WillReturn[2793510720] = 1792;
WillReturn[3491888400] = 1920;
WillReturn[4655851200] = 2016;
WillReturn[5587021440] = 2048;
WillReturn[6983776800] = 2304;
WillReturn[10475665200] = 2400;
WillReturn[13967553600] = 2688;
WillReturn[20951330400] = 2880;
WillReturn[27935107200] = 3072;
WillReturn[41902660800] = 3360;
WillReturn[48886437600] = 3456;
WillReturn[64250746560] = 3584;
WillReturn[73329656400] = 3600;
WillReturn[80313433200] = 3840;
WillReturn[97772875200] = 4032;
WillReturn[128501493120] = 4096;
WillReturn[146659312800] = 4320;
WillReturn[160626866400] = 4608;
WillReturn[240940299600] = 4800;
WillReturn[293318625600] = 5040;
WillReturn[321253732800] = 5376;
WillReturn[481880599200] = 5760;
WillReturn[642507465600] = 6144;
WillReturn[963761198400] = 6720;
WillReturn[1124388064800] = 6912;
WillReturn[1606268664000] = 7168;
WillReturn[1686582097200] = 7200;
WillReturn[1927522396800] = 7680;
WillReturn[2248776129600] = 8064;
WillReturn[3212537328000] = 8192;
WillReturn[3373164194400] = 8640;
WillReturn[4497552259200] = 9216;
WillReturn[6746328388800] = 10080;
WillReturn[8995104518400] = 10368;
WillReturn[9316358251200] = 10752;
WillReturn[13492656777600] = 11520;
WillReturn[18632716502400] = 12288;
WillReturn[26985313555200] = 12960;
WillReturn[27949074753600] = 13440;
WillReturn[32607253879200] = 13824;
WillReturn[46581791256000] = 14336;
WillReturn[48910880818800] = 14400;
WillReturn[55898149507200] = 15360;
WillReturn[65214507758400] = 16128;
WillReturn[93163582512000] = 16384;
WillReturn[97821761637600] = 17280;
WillReturn[130429015516800] = 18432;
WillReturn[195643523275200] = 20160;
WillReturn[260858031033600] = 20736;
WillReturn[288807105787200] = 21504;
WillReturn[391287046550400] = 23040;
WillReturn[577614211574400] = 24576;
WillReturn[782574093100800] = 25920;
WillReturn[866421317361600] = 26880;
WillReturn[1010824870255200] = 27648;
WillReturn[1444035528936000] = 28672;
WillReturn[1516237305382800] = 28800;
WillReturn[1732842634723200] = 30720;
WillReturn[2021649740510400] = 32256;
WillReturn[2888071057872000] = 32768;
WillReturn[3032474610765600] = 34560;
WillReturn[4043299481020800] = 36864;
WillReturn[6064949221531200] = 40320;
WillReturn[8086598962041600] = 41472;
WillReturn[10108248702552000] = 43008;
WillReturn[12129898443062400] = 46080;
WillReturn[18194847664593600] = 48384;
WillReturn[20216497405104000] = 49152;
WillReturn[24259796886124800] = 51840;
WillReturn[30324746107656000] = 53760;
WillReturn[36389695329187200] = 55296;
WillReturn[48519593772249600] = 57600;
WillReturn[60649492215312000] = 61440;
WillReturn[72779390658374400] = 62208;
WillReturn[74801040398884800] = 64512;
WillReturn[106858629141264000] = 65536;
WillReturn[112201560598327200] = 69120;
WillReturn[149602080797769600] = 73728;
WillReturn[224403121196654400] = 80640;
WillReturn[299204161595539200] = 82944;
WillReturn[374005201994424000] = 86016;
WillReturn[448806242393308800] = 92160;
WillReturn[673209363589963200] = 96768;
WillReturn[748010403988848000] = 98304;
WillReturn[897612484786617600] = 103680;
return WillReturn;
}
}