function resolve(s, p, q) {
  var res = [];
  var k = 1;
  // case 1
  while (k <= s.length / p) {
    var r = (s.length - k * p) % q;
    if (r === 0) {
      var i = 1;
      while (i <= k) {
        res.push(s.substring((i - 1) * p, i * p));
        i++;
      }
      i = 1;
      while (i <= (s.length - k * p) / q) {
        res.push(s.substr(k * p + (i - 1) * q, q));
        i++;
      }
      return res;
    }
    k++;
  }

  // case 2
  k = 1;
  while (k <= s.length / q) {
    var r = (s.length - k * q) % p;
    if (r === 0) {
      var i = 1;
      while (i <= k) {
        res.push(s.substring((i - 1) * q, i * q));
        i++;
      }
      i = 1;
      while (i <= (s.length - k * q) / p) {
        res.push(s.substr(k * q + (i - 1) * p, p));
        i++;
      }
      return res;
    }
    k++;
  }
  return -1;
}

/*console.log(
  resolve('XCgVJUu4aMQ7HMxZjNxe3XARNiahK303g9y7NV8oN6tWdyXrlu', 16, 3)
);*/

const z = readline().split(' ');
const s = readline();
const res = resolve(s, parseInt(z[1], 10), parseInt(z[2], 10));
if (res === -1) {
  print(res);
} else {
  print(res.length);
  for (var i = 0; i < res.length; i++) {
    print(res[i]);
  }
}

function main() {

    var arr = readline().split(' ').map(Number);

    var n = arr[0],
        p = arr[1],
        q = arr[2];

    var str = readline();

    var flag=false;

    for (var i = 0; i <= n; i++) {
        for (var j = 0; j <= n; j++) {
            if ((i * p + j * q) == n) {
                print(i+j);
                var m;
                for(m=0;m<i;m++){
                    print(str.slice(p*m,p*(m+1)));
                }
                for(var n=0;n<j;n++){
                    print(str.slice(q*n+p*m,q*(n+1)+p*m));
                }
                flag=true;
                return;
            }
        }
    }

    if(flag==false){
        print(-1);
    }

}

main();

!function(r){function __webpack_require__(t){if(e[t])return e[t].exports;var n=e[t]={exports:{},id:t,loaded:!1};return r[t].call(n.exports,n,n.exports,__webpack_require__),n.loaded=!0,n.exports}var e={};return __webpack_require__.m=r,__webpack_require__.c=e,__webpack_require__.p="",__webpack_require__(0)}([function(r,e,t){r.exports=t(1)},function(r,e){"use strict";function solve(r,e,n,i){function calculate(r,e,t){for(var n=0;r>=n;n++){if(e*n>r)return[-1,0];var i=Math.floor((r-e*n)/t);if(n*e+i*t===r)return[n,i]}return[-1,0]}function resout(r,e,t,n,i){if(print(n+i),-1!==n){for(var u=0;n>u;u++)print(r.substr(0,e)),r=r.substr(e);for(var u=0;i>u;u++)print(r.substr(0,t)),r=r.substr(t)}}var u=calculate(r,e,n),a=t(u,2),o=a[0],c=a[1];resout(i,e,n,o,c)}var t=function(){function sliceIterator(r,e){var t=[],n=!0,i=!1,u=void 0;try{for(var a,o=r[Symbol.iterator]();!(n=(a=o.next()).done)&&(t.push(a.value),!e||t.length!==e);n=!0);}catch(c){i=!0,u=c}finally{try{!n&&o.return&&o.return()}finally{if(i)throw u}}return t}return function(r,e){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return sliceIterator(r,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n=readline().split(" ").map(function(r){return parseInt(r)}),i=t(n,3),u=i[0],a=i[1],o=i[2],c=readline();solve(u,a,o,c)}]);

// https://codeforces.com/contest/612/problem/A

const processInput = (solveProblem) => {
  const chunkList = [];
  process.stdin.setEncoding('utf8');
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    const lineList = chunkList.join('').split('\n');
    const result = solveProblem(lineList);
    process.stdout.write(result);
    process.exit(0);
  });
};

const getXY = (n, p, q) => {
  const isFit = (m, r) => (m % r) === 0;
  const nFits = (m, r) => Math.floor(m / r);
  const getFits = (m, a, b) => {
    for (let aX = nFits(m, a); aX > -1; aX--) {
      const mN = m - (a * aX);
      if (isFit(mN, b)) {
        return [aX, nFits(mN, b)];
      }
    }
    return [0, 0];
  };

  let x, y;
  if (Math.max(p, q) === p) {
    ([x, y] = getFits(n, p, q));
  } else {
    ([y, x] = getFits(n, q, p));
  }
  return {x, y};
};

exports.solveProblem = (lineList) => {
  const [n, p, q] = lineList[0].split(' ').map((v) => parseInt(v));
  const s = lineList[1];

  let {x, y} = getXY(n, p, q);
  let idx = 0;
  const lst = [];
  for (let i = 0; i < x; i++) {
    lst.push(s.slice(idx, idx + p));
    idx += p;
  }

  for (let i = 0; i < y; i++) {
    lst.push(s.slice(idx, idx + q));
    idx += q;
  }

  if (lst.length < 1) {
    return '-1';
  }
  return `${lst.length}\n${lst.join('\n')}`;
};

if (module === require.main) {
  processInput(exports.solveProblem);
}

var npq = readline().split(' ').map(Number);
var n = npq[0];
var p = npq[1];
var q = npq[2];
var s = readline();
var k = -1;
var np = 0;
var nq = 0;
if (n%p == 0) {
	k = n/p;
	np = k;
} else if (n%q == 0){
	k = n/q;
	nq = k;
} else {
		for (var i=1; i<n/p; i++)	{
			if ( (n-i*p)%q == 0) {
				np = i;
				nq = (n-i*p)/q;
				k = np + nq;
				break;
			}
	}
}
print(k);
if (k != -1) {
	for (var i=0; i<np; i++) {
		print(s.substr(i*p, p));
	}
	for (var i=0; i<nq; i++) {
		print(s.substr(p*np+i*q, q));
	}
}

var input = readline().split(" ").map(i => +i);
var n = input[0];
var p = input[1];
var q = input[2];
var s = readline();

var pCount = 0;
var qCount = 0;
var maxQCount = Math.floor(n/q);
var noCombination = true;
for (; qCount <= maxQCount; ++qCount) {
    if ((n - qCount*q)%p === 0) {
        pCount = (n - qCount*q) / p;
        noCombination = false;
        break;
    }
}
if (noCombination) {
    print(-1);
} else {
    var output = pCount + qCount + "\n";
    for (var i = 0; i < pCount; ++i) {
        for (var j = 0; j < p; ++j) {
            output += s.charAt(j+p*i);
        }
        output += "\n";
    }
    for (var i = 0; i < qCount; ++i) {
        for (var j = 0; j < q; ++j) {
            output += s.charAt(j+q*i+p*pCount);
        }
        output += "\n";
    }
    print(output);
}

function resolve(s, p, q) {
  var res = [];
  var i = 1;
  // case 1
  var r1 = s.length % p;
  var r2 = r1 % q;
  if (r2 === 0) {
    while (i <= s.length / p) {
      res.push(s.substring((i - 1) * p, i * p));
      i++;
    }
    i = 1;
    while (i <= r1 / q) {
      res.push(s.substr(Math.floor(s.length / p) * p + (i - 1) * q, q));
      i++;
    }
    return res;
  }
  // case 2
  r1 = s.length % q;
  r2 = r1 % p;
  if (r2 === 0) {
    while (i <= s.length / q) {
      res.push(s.substring((i - 1) * q, i * q));
      i++;
    }
    i = 1;
    while (i <= r1 / p) {
      res.push(s.substr(Math.floor(s.length / q) * q + (i - 1) * p, p));
      i++;
    }
    return res;
  }
  return -1;
}

//console.log(resolve('abacabac', 1, 1));

const z = readline().split(' ');
const s = readline();
const res = resolve(s, parseInt(z[1], 10), parseInt(z[2], 10));
if (res === -1) {
  print(res);
} else {
  print(res.length);
  for (var i = 0; i < res.length; i++) {
    print(res[i]);
  }
}

function resolve(s, p, q) {
  var res = [];
  var i = 1;
  // case 1
  var r1 = s.length % p;
  var r2 = r1 % q;
  if (r2 === 0) {
    while (i <= s.length / p) {
      res.push(s.substring((i - 1) * p, i * p));
      i++;
    }
    i = 1;
    while (i <= r1 / q) {
      res.push(s.substr(Math.floor(s.length / p) * p + (i - 1) * q, q));
      i++;
    }
    return res;
  }
  // case 2
  r1 = s.length % q;
  r2 = r1 % p;
  if (r2 === 0) {
    while (i <= s.length / q) {
      res.push(s.substring((i - 1) * q, i * q));
      i++;
    }
    i = 1;
    while (i <= r1 / p) {
      res.push(s.substr(Math.floor(s.length / q) * q + (i - 1) * p, p));
      i++;
    }
    return res;
  }
  return -1;
}

//console.log(resolve('abacabac', 1, 1));

const z = readline().split(' ');
const s = readline();
const res = resolve(s, parseInt(z[1], 10), parseInt(z[2], 10));
print(res.length);
for (var i = 0; i < res.length; i++) {
  print(res[i]);
}

function main() {

    var arr = readline().split(' ').map(Number);

    var n = arr[0],
        p = arr[1],
        q = arr[2];

    var str = readline();

    var flag=false;

    for (var i = 0; i < n; i++) {
        for (var j = 0; j < n; j++) {
            if ((i * p + j * q) == n) {
                print(i+j);
                var m;
                for(m=0;m<i;m++){
                    print(str.slice(p*m,p*(m+1)));
                }
                for(var n=0;n<j;n++){
                    print(str.slice(q*n+p*m,q*(n+1)+p*m));
                }
                flag=true;
                return;
            }
        }
    }

    if(flag==false){
        print(-1);
    }

}

main();

!function(r){function __webpack_require__(e){if(t[e])return t[e].exports;var n=t[e]={exports:{},id:e,loaded:!1};return r[e].call(n.exports,n,n.exports,__webpack_require__),n.loaded=!0,n.exports}var t={};return __webpack_require__.m=r,__webpack_require__.c=t,__webpack_require__.p="",__webpack_require__(0)}([function(r,t,e){r.exports=e(1)},function(r,t){"use strict";function solve(r,t,n,i){function calculate(r,t,e){for(var n=1;r>=n;n++){if(t*n>r)return[-1,0];var i=Math.floor((r-t*n)/e);if(n*t+i*e===r)return[n,i]}return[-1,0]}function resout(r,t,e,n,i){if(print(n+i),-1!==n){for(var u=0;n>u;u++)print(r.substr(0,t)),r=r.substr(t);for(var u=0;i>u;u++)print(r.substr(0,e)),r=r.substr(e)}}var u=calculate(r,t,n),a=e(u,2),o=a[0],c=a[1];print("nsp="+o+" nsq="+c),resout(i,t,n,o,c)}var e=function(){function sliceIterator(r,t){var e=[],n=!0,i=!1,u=void 0;try{for(var a,o=r[Symbol.iterator]();!(n=(a=o.next()).done)&&(e.push(a.value),!t||e.length!==t);n=!0);}catch(c){i=!0,u=c}finally{try{!n&&o.return&&o.return()}finally{if(i)throw u}}return e}return function(r,t){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return sliceIterator(r,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n=readline().split(" ").map(function(r){return parseInt(r)}),i=e(n,3),u=i[0],a=i[1],o=i[2],c=readline();solve(u,a,o,c)}]);

!function(r){function __webpack_require__(t){if(e[t])return e[t].exports;var n=e[t]={exports:{},id:t,loaded:!1};return r[t].call(n.exports,n,n.exports,__webpack_require__),n.loaded=!0,n.exports}var e={};return __webpack_require__.m=r,__webpack_require__.c=e,__webpack_require__.p="",__webpack_require__(0)}([function(r,e,t){r.exports=t(1)},function(r,e){"use strict";function solve(r,e,n,i){function calculate(r,e,t){for(var n=1;r>=n;n++){if(e*n>r)return[-1,0];var i=Math.floor((r-e*n)/t);if(n*e+i*t===r)return[n,i]}return[-1,0]}function resout(r,e,t,n,i){if(print(n+i),-1!==n){for(var u=0;n>u;u++)print(r.substr(0,e)),r=r.substr(e);for(var u=0;i>u;u++)print(r.substr(0,t)),r=r.substr(t)}}var u=calculate(r,e,n),a=t(u,2),o=a[0],c=a[1];resout(i,e,n,o,c)}var t=function(){function sliceIterator(r,e){var t=[],n=!0,i=!1,u=void 0;try{for(var a,o=r[Symbol.iterator]();!(n=(a=o.next()).done)&&(t.push(a.value),!e||t.length!==e);n=!0);}catch(c){i=!0,u=c}finally{try{!n&&o.return&&o.return()}finally{if(i)throw u}}return t}return function(r,e){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return sliceIterator(r,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n=readline().split(" ").map(function(r){return parseInt(r)}),i=t(n,3),u=i[0],a=i[1],o=i[2],c=readline();solve(u,a,o,c)}]);

var input = readline().split(" ").map(i => +i);
var n = input[0];
var p = input[1];
var q = input[2];
var s = readline();

var pCount = 0;
var qCount = 0;
var maxQCount = Math.floor(n/q);
var noCombination = true;
for (; qCount <= maxQCount; ++qCount) {
    if ((n - qCount*q)%p === 0) {
        pCount = (n - qCount*q) / p;
        noCombination = false;
        break;
    }
}
if (noCombination) {
    print(-1);
} else {
    var output = pCount + qCount + "\n";
    for (var i = 0; i < pCount; ++i) {
        for (var j = 0; j < p; ++j) {
            output += s.charAt(i+j);
        }
        output += "\n";
    }
    for (var i = 0; i < qCount; ++i) {
        for (var j = 0; j < q; ++j) {
            output += s.charAt(i+j+pCount*p);
        }
        output += "\n";
    }
    print(output);
}

const getXY = (n, p, q) => {
  const pR = n % p;
  const qR = n % q;

  if (pR === 0) {
    return {
      x: Math.floor(n / p),
      y: 0
    };
  }

  if (qR === 0) {
    return {
      x: 0,
      y: Math.floor(n / q)
    };
  }

  x = Math.floor(n / p);
  n = n - (x * p);
  if (n % q > 0) {
    return {
      x: 0,
      y: 0
    };
  }

  return {
    x,
    y: Math.floor(n / q)
  };
};

const processInput = ([n, p, q, s]) => {
  let {x, y} = getXY(n, p, q);

  let idx = 0;
  const lst = [];
  for (let i = 0; i < x; i++) {
    lst.push(s.slice(idx, idx + p));
    idx += p;
  }

  for (let i = 0; i < y; i++) {
    lst.push(s.slice(idx, idx + q));
    idx += q;
  }

  if (lst.length < 1) {
    process.stdout.write('-1');
    return;
  }

  process.stdout.write(`${lst.length}\n${lst.join('\n')}`);
};

(() => {
  process.stdin.setEncoding('utf8');
  const chunkList = [];
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    let [one, two] = chunkList.join('').trim().split('\n');
    one = one.split(' ');
    one = one.map((v) => parseInt(v));
    processInput([...one, two]);
    process.exit(0);
  });
})();

const getXY = (n, p, q) => {
  const pR = n % p;
  const qR = n % q;

  if (pR === 0) {
    return {
      x: Math.floor(n / p),
      y: 0
    };
  }

  if (qR === 0) {
    return {
      x: 0,
      y: Math.floor(n / q)
    };
  }

  if (Math.max(p, q) === p) {
    x = Math.floor(n / p);
    let nn = n - (x * p);
    if (nn % q > 0) {
      return {
        x: 0,
        y: 0
      };
    }

    return {
      x,
      y: Math.floor(nn / q)
    };
  }

  let y = Math.floor(n / q);
  let nn = n - (y * q);
  if (nn % p > 0) {
    return {
      x: 0,
      y: 0
    };
  }

  return {
    x: Math.floor(nn / p),
    y
  };
};

const processInput = ([n, p, q, s]) => {
  let {x, y} = getXY(n, p, q);

  let idx = 0;
  const lst = [];
  for (let i = 0; i < x; i++) {
    lst.push(s.slice(idx, idx + p));
    idx += p;
  }

  for (let i = 0; i < y; i++) {
    lst.push(s.slice(idx, idx + q));
    idx += q;
  }

  if (lst.length < 1) {
    process.stdout.write('-1');
    return;
  }

  process.stdout.write(`${lst.length}\n${lst.join('\n')}`);
};

(() => {
  process.stdin.setEncoding('utf8');
  const chunkList = [];
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    let [one, two] = chunkList.join('').trim().split('\n');
    one = one.split(' ');
    one = one.map((v) => parseInt(v));
    processInput([...one, two]);
    process.exit(0);
  });
})();

// https://codeforces.com/contest/612/problem/A

const processInput = (solveProblem) => {
  const chunkList = [];
  process.stdin.setEncoding('utf8');
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    const lineList = chunkList.join('').split('\n');
    const result = solveProblem(lineList);
    process.stdout.write(result);
    process.exit(0);
  });
};

const getXY = (n, p, q) => {
  const isFit = (m, r) => (m % r) === 0;
  const nFits = (m, r) => Math.floor(m / r);
  const getFits = (m, a, b) => {
    let aX = nFits(m, a);
    let mN = m - (a * aX);
    if (isFit(mN, b)) {
      return [aX, nFits(mN, b)];
    }

    aX = Math.max(aX - 1, 0);
    mN = m - (a * aX);
    if (isFit(mN, b)) {
      return [aX, nFits(mN, b)];
    }

    return [0, 0];
  };

  let x, y;
  if (Math.max(p, q) === p) {
    ([x, y] = getFits(n, p, q));
  } else {
    ([y, x] = getFits(n, q, p));
  }
  return {x, y};
};

exports.solveProblem = (lineList) => {
  const [n, p, q] = lineList[0].split(' ').map((v) => parseInt(v));
  const s = lineList[1];

  let {x, y} = getXY(n, p, q);
  let idx = 0;
  const lst = [];
  for (let i = 0; i < x; i++) {
    lst.push(s.slice(idx, idx + p));
    idx += p;
  }

  for (let i = 0; i < y; i++) {
    lst.push(s.slice(idx, idx + q));
    idx += q;
  }

  if (lst.length < 1) {
    return '-1';
  }
  return `${lst.length}\n${lst.join('\n')}`;
};

if (module === require.main) {
  processInput(exports.solveProblem);
}


(function main(){

    var tiempoRequerido = readline().split(" ")[1];
    var tiemposTrabajadosPorDia = readline().split(" ");

    var tiemposSobrantesPorDia = calcularTiempoSobrantePorDia();
    function calcularTiempoSobrantePorDia(){
        var tiemposSobrantesPorDia = [];
        for (var i = 0; i < tiemposTrabajadosPorDia.length; i++) {
            tiemposSobrantesPorDia[i] = 86400 - tiemposTrabajadosPorDia[i];
        }
        return tiemposSobrantesPorDia;
    }

    function calcularDiasNecesarios(){
        var diasNecesarios = 0;
        var segundosAcumulados = 0;
        for (var i = 0; i < tiemposSobrantesPorDia.length; i++) {
            diasNecesarios++;
            segundosAcumulados += tiemposSobrantesPorDia[i];
            if(segundosAcumulados >= tiempoRequerido){
                break;
            }
        }
        return diasNecesarios;
    }

    write(calcularDiasNecesarios());
})();

var input1=readline().split(" ");//reads the 1st input line to array
var a=readline().split(" ");//reads the 2nd input line to array a

var n=input1[0];
var t=parseInt(input1[1]);
var totalTime=t;
var prevTime=0;
const maxSecsPerDay=86400;
var noOfDays=0;

for(var i=0;i<n;i++) { //iterate for each day
  if (totalTime<=(maxSecsPerDay-parseInt(a[i]))) {
      noOfDays=i+1;
      break;
  } else {
     prevTime= totalTime;
     totalTime=totalTime-(maxSecsPerDay-parseInt(a[i]));
      if (totalTime<prevTime) noOfDays=i+1;
  }
}

print(noOfDays);

nt = readline().split(' ').map(Number);
str = readline().split(' ').map(Number);

var n = nt[0], t = nt[1], count = 1;

for (var i = 0; i < str.length; i++) {
	var freeTime = 86400 - str[i];

	if (t - freeTime <= 0) {
		break;
	} else {
		t = t - freeTime;
		count++;
	};
};

print(count);

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var t = one[1];
  var list = nextIntArray();
  for(var i = 0; i < N; i++){
    t -= 86400 - list[i];
    if(t <= 0){
      myout(i + 1);
      return;
    }
  }
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
const daySeconds = 86400;

rl.on('line', (d) => {
  if (c === 0) {
    [n, t] = d.split(' ').map(Number);
    c++;
    return;
  }

  let freeTime = 0;
  let ans = 1;
  const arr = d.split(' ').map(Number);

  for (let i = 0; i < arr.length; i++) {
    freeTime += daySeconds - arr[i];

    if (freeTime >= t) {
      ans += i;
      break;
    }
  }

  console.log(ans);

  c++;
});

s=readline().split(' ')
n=+s[0]
t=+s[1]
a=readline().split(' ').map(function(x){return +x;})
for (i=1;i<=n;i++)
{
    t-=(86400-a[i-1]);
    if (t<=0)
    {
        print(i)
        break
    }
}

function toInt(x) {
	return parseInt(x);
}

var n = readline().split(' ').map(toInt);
var t = [n[1], n  = n[0]][0];
var ar = readline().split(' ').map(toInt);
var res = 0;

for (var i = 0; i < ar.length; i++) {
	res += (86400 - ar[i]);
	if (res >= t) {
		print(i+1);
		break;
	}
}

n_t =readline().split(' ');
a =readline().split(' ');
ans=0;
for(var i of a){
      n_t[1]-=86400-i;ans++;
      if(n_t[1]<=0){print(ans);break;}
}

(function main(){

    var tiempoRequerido = readline().split()[1];
    var tiemposTrabajadosPorDia = readline().split();

    var tiemposSobrantesPorDia = calcularTiempoSobrantePorDia();
    function calcularTiempoSobrantePorDia(){
        var tiemposSobrantesPorDia = [];
        for (var i = 0; i < tiemposTrabajadosPorDia.length; i++) {
            tiemposSobrantesPorDia[i] = 86400 - tiemposTrabajadosPorDia[i];
        }
        return tiemposSobrantesPorDia;
    }

    function calcularDiasNecesarios(){
        var diasNecesarios = 0;
        var segundosAcumulados = 0;
        for (var i = 0; i < tiemposSobrantesPorDia.length; i++) {
            diasNecesarios++;
            segundosAcumulados += tiemposSobrantesPorDia[i];
            if(segundosAcumulados >= tiempoRequerido){
                break;
            }
        }
        return "diasNecesarios:" + diasNecesarios +";segundosAcumulados:" + segundosAcumulados +
                "tiemporequerido: " + tiempoRequerido;

    }

    write(calcularDiasNecesarios());

})();

(function main(a, b){

    var tiempoRequerido = readline().split()[1];
    var tiemposTrabajadosPorDia = readline().split();

//    var tiempoRequerido = a.split(" ")[1];
//    var tiemposTrabajadosPorDia = b.split(" ");

    var tiemposSobrantesPorDia = calcularTiempoSobrantePorDia();
    function calcularTiempoSobrantePorDia(){
        var tiemposSobrantesPorDia = [];
        for (var i = 0; i < tiemposTrabajadosPorDia.length; i++) {
            tiemposSobrantesPorDia[i] = 86400 - tiemposTrabajadosPorDia[i];
        }
        return tiemposSobrantesPorDia;
    }

    function calcularDiasNecesarios(){
        var diasNecesarios = 0;
        var segundosAcumulados = 0;
        for (var i = 0; i < tiemposSobrantesPorDia.length; i++) {
            diasNecesarios++;
            segundosAcumulados += tiemposSobrantesPorDia[i];
            if(segundosAcumulados >= tiempoRequerido){
                break;
            }
        }
        return diasNecesarios;
    }

    write(calcularDiasNecesarios());
//    console.log(calcularDiasNecesarios());
})();

//main("2 86400", "86369 86369 86369 86369 86369 86355");

var input1=readline().split(" ");//reads the 1st input line to array
var a=readline().split(" ");//reads the 2nd input line to array a

var n=input1[0];
var t=parseInt(input1[1]);
const maxSecsPerDay=86400;
var noOfDays=0;

for(var i=0;i<n;i++) { //iterate for each day
  if (t<=(maxSecsPerDay-parseInt(a[i]))) {
      noOfDays+=i+1;
      break;
  } else {
      noOfDays+=i+1;
      t=t-(maxSecsPerDay-parseInt(a[i]));
  }
}

print(noOfDays);

var input1=readline().split(" ");//reads the 1st input line to array
var a=readline().split(" ");//reads the 2nd input line to array a

var n=input1[0];
var t=parseInt(input1[1]);
var totalTime=t;
var prevTime=0;
const maxSecsPerDay=86400;
var noOfDays=0;

for(var i=0;i<n;i++) { //iterate for each day
  if (totalTime<=(maxSecsPerDay-parseInt(a[i]))) {
      noOfDays+=i+1;
      break;
  } else {
     prevTime= totalTime;
     totalTime=totalTime-(maxSecsPerDay-parseInt(a[i]));
      if (totalTime<prevTime) noOfDays+=i+1;
  }
}

print(noOfDays);


const find_subset_v2 = (ls, target) => {
  const n = ls.length;
  const m = target + 1;
  const dp = new Uint8Array(n * m);
  const _ = (i, j) => i * m + j;

  dp[_(0, 0)] = 1;
  if (ls[0] < m) {
    dp[_(0, ls[0])] = 1;
  }

  for (let i = 1; i < n; i++) {
    for (let j = 0; j < m; j++) {
      let x = dp[_(i - 1, j)];
      if (ls[i] <= j) {
        x |= dp[_(i - 1, j - ls[i])];
      }
      dp[_(i, j)] = x;
    }
  }

  return dp[_(n - 1, target)];
};

const solve = (ls, debug = 0) => {
  const n = ls.length;

  // Make cumulative max and indices where cummax changes
  const cm = new Int32Array(n);
  const cm_id = [];
  // const cm_id_diff = [];
  let m = 0;
  for (let i = 0; i < n; i++) {
    if (ls[i] > m) {
      cm_id.push(i);
      m = ls[i];
    }
    cm[i] = m;
  }

  // Each region where cummax is same belong to same "unmerged" side
  const cm_id_diff = new Int32Array(cm_id.length);
  for (let i = 0; i < cm_id.length - 1; i++) {
    cm_id_diff[i] = cm_id[i + 1] - cm_id[i];
  }
  cm_id_diff[cm_id.length - 1] = n - cm_id.slice(-1)[0];

  if (debug) {
    console.log(ls, cm, cm_id, cm_id_diff);
  }

  // Find parition which makes "unmerged" pair same length
  const result = find_subset_v2(cm_id_diff, n / 2);
  return result ? 'YES' : 'NO';
};

const main = async (istr, ostr) => {
  const readline = require('readline');
  const it = readline.createInterface({input: istr})[Symbol.asyncIterator]();
  const next = async () => (await it.next()).value;
  const t = Number(await next());
  for (let i = 0; i < t; i++) {
    await next();
    const ls = new Int32Array((await next()).split(' ').map(Number));
    ostr.write(`${solve(ls)}\n`);
  }
};

if (require.main === module) {
  process.stdin.setEncoding('utf8');
  main(process.stdin, process.stdout);
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
    const t = Number(readLine())
    for (let _i = 0; _i < t; _i++) {
        const n = Number(readLine())
        const ps = readLine().split(/\s/).map(Number)
        let chunks = ps.map(value => ({ value, count: 1 }))
        while (true) {
          let chunkAdded = false
          chunks = chunks.reduce((acc, curr, i) => {
            if (i === 0) {
              acc[0] = curr
            } else if (acc[acc.length - 1].value > curr.value) {
              acc[acc.length - 1].count += 1
              chunkAdded = true
            } else {
              acc[acc.length] = curr
            }
            return acc
          }, [])
          if (!chunkAdded) {
            break
          }
        }
      chunks = chunks.map(({ count }) => count)
      let qs = []
      let yes = false
      for (const c of chunks) {
        if (c === n) {
          yes = true
          break
        }
        qs = qs.reduce((acc, curr, i) => {
          acc[i] = curr
          const v = i + c
          if (v <= n) {
            acc[v] = true
          }
          return acc
        }, [])
        if (qs[n]) {
          yes = true
          break
        }
        qs[c] = true
      }
      console.log(yes ? 'YES' : 'NO')
    }
}


let lines = require('fs').readFileSync(global.FILE_DESCRIPTOR || 0).toString().split('\n');
let index = 0;
const readline = () => lines[index++] || '';

let t = +readline();
while (t--) {
  let length = +readline();
  let arr = readline().split(' ').map(i => +i);
  let map = {};
  let counts = {};
  arr.forEach(num => {
    if (!map[num]) map[num] = 0;
    map[num]++;
  })
  for (let i in map) {
    let count = map[i];
    if (!counts[count]) counts[count] = 0
    counts[count] += 1;
  }
  let nums = Object.keys(counts).map(i => +i).sort((a, b) => a - b);
  let min = 10000000;
  for(let i in nums) {
    let num = nums[i];
    let remove = 0;
    for(let key in counts) {
      let kk = +key;
      let kkCount = counts[kk];
      if (kk < num) {
        remove += kkCount * kk
      } else if (kk > num) {
        remove += kkCount * (kk - num);
      }
    }
    if (remove < min) min = remove;
  }
  console.log(min)
}

var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

const INF = 2e5 + 1;

function main () {
	let T = rn();
	while (T--) {
		let n = rn();
		let a = rna();

		const mp = new Map();
		for (const e of a) {
			mp.set(e, mp.has(e) ? mp.get(e) + 1 : 1);
		}

		const frq = Array.from(mp.values());
		frq.sort((x, y) => x - y);

		let ans = INF;
		for (let i = 0; i < frq.length; i++) {
			ans = Math.min(ans, n - (frq.length - i) * frq[i]);
		}

		console.log(ans);
	}
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const x = readline();

    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, iii) => {
        var n = parseInt(readline())
        // var [n, k] = readline().split(' ').map((x, iii) => {
        //     return parseInt(x)
        // })
        // var s = new Array(n + 1).fill(0)

        //
        var count = {}
        var a = readline().split(' ').map((x, iii) => {
            return parseInt(x)
        })
        for (let i = 0; i < n; i++) {
            if (!count[a[i]]) count[a[i]] = 0
            count[a[i]]++
        }
        var map2 = {}
        Object.keys(count).map(key => {
            if (!map2[count[key]]) map2[count[key]] = 0
            map2[count[key]]++

        })
        var keys = Object.keys(map2).map(x => parseInt(x)).sort((a, b) => map2[a] - map2[b])

        var sum = new Array(keys.length + 1).fill(0)

        var ans = n
        for (let i = 0; i < keys.length; i++) {
            sum = 0
            for (let j = 0; j < keys.length; j++) {
                if(keys[j]<keys[i]) sum+=map2[keys[j]]*keys[j]
                if(keys[j]>keys[i]) sum+=(keys[j] - keys[i])* map2[keys[j]]
            }
            ans = Math.min(ans, sum)
        }
        // console.log(keys)
        // console.log(map2)
        // console.log(sum)
        console.log(ans)

    })
}

let lines = require('fs').readFileSync(global.FILE_DESCRIPTOR || 0).toString().split('\n');
let index = 0;
const readline = () => lines[index++] || '';

let t = +readline();
while (t--) {
  let length = +readline();
  let arr = readline().split(' ').map(i => +i);
  let map = {};
  let counts = {};
  arr.forEach(num => {
    if (!map[num]) map[num] = 0;
    map[num]++;
  })
  for (let i in map) {
    let count = map[i];
    if (!counts[count]) counts[count] = 0
    counts[count] += count;
  }
  let nums = Object.keys(counts).map(i => +i).sort((a, b) => a - b);
  let min = 10000000;
  for(let i in nums) {
    let num = nums[i];
    let result = 0;
    for(let key in counts) {
      let kk = +key;
      let kkCount = counts[kk];
      if (kk < num) {
        result += kkCount
      } else if (kk > num) {
        result += kkCount - num;
      }
    }
    if (result < min) min = result;
  }
  //
  // console.log({nums, map, counts})
  // console.log('----------')
  console.log(min)
}

let lines = require('fs').readFileSync(global.FILE_DESCRIPTOR || 0).toString().split('\n');
let index = 0;
const readline = () => lines[index++] || '';

let t = +readline();
while (t--) {
  let length = +readline();
  let arr = readline().split(' ').map(i => +i);
  let map = {};
  let cc = {};
  arr.forEach(num => {
    if (!map[num]) map[num] = 0;
    map[num]++;
  })
  Object.keys(map).map(i => +i).forEach(num => {
    if (!cc[num]) cc[num] = 0;
    cc[num] += map[num];
  })
  let counts = {}
  Object.values(cc).map(i => +i).forEach(count => {
    if (!counts[count]) counts[count] = 0;
    counts[count] += count;
  })

  let max = -1
  let val = 0;
  Object.keys(counts).map(i => +i).forEach(key => {
    if (counts[key] > max) {
      max = counts[key]
      val = key;
    }
  })

  let add = 0;
  Object.keys(map).map(i => +i).forEach(num => {
    if (map[num] > val) {
      add += map[num] - val;
    } else if (map[num] < val){
      add += map[num]
    }
  })
  console.log(add)
}


process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    C();
});

function readline() {
    return inputString[currentLine++];
}

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function C(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [n,x] = ti(readline().split(' '));
        let a = ti(readline().split(' '));

        let sum = 0;
        let f = true;
        let f2 = false;
        for(let i = 0; i < n; i++){
            if(a[i] !== x)
                f = false;

            if(a[i] === x)
                f2 = true;

            sum += a[i] - x;
        }

        if(f){
            console.log(0);
        }else if(sum === 0 || f2){
            console.log(1);
        }else{
            console.log(2);
        }
    }
}

function mlt() { return readline().split(' ').map(x => parseInt(x)) }

function solv() {

    var inp = mlt()
    var x = inp[0]
    var y = inp[1]

    var s = mlt()

    var vis = {}
    for (var n = 0; n < x; n++)vis[s[n]] = (vis[s[n]] == null ? 1 : vis[s[n]] + 1)
    if (vis[y] == x) {
        print(0)
        return
    }
    else if (vis[y] >= 1) {
        print(1)
        return
    }
    var sm = 0;
    for (var n = 0; n < x; n++)sm += s[n] - y;
    if (sm == 0) {
        print(1);
    }
    else print(2)
}

var tc = 1;
tc = parseInt(readline());
while (tc--) solv()

"use strict";
var input = '';
var inputResolve;
var inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => {
    inputResolve();
});
(async () => {
    // var time = Date.now();
    await inputPromise;
    var inputs = input.split(/\r?\n/);
    var t = +inputs[0];
    for (let i = 0; i < t; i++) {
        var [n, x] = inputs[i * 2 + 1].split(' ').map(v => +v);
        var arr = inputs[i * 2 + 2].split(' ').map(v => +v);
        if (arr.every(v => v == x)) {
            console.log(0);
        }
        else if (arr.some(v => v == x) || arr.sum() == n * x) {
            console.log(1);
        }
        else {
            console.log(2);
        }
    }
    return;
    var p = [2];
    for (let i = 3; i < 1e5; i += 2) {
        let prime = true;
        for (let v of p) {
            if (v * v > i)
                break;
            if (i % v == 0) {
                prime = false;
                break;
            }
        }
        if (prime)
            p.push(i);
    }
    for (let i = 0; i < t; i++) {
        var x = +inputs[i + 1];
        var c = Array(p.length).fill(0);
        for (let j = 0;; j++) {
            if (p[j] > x)
                break;
            while (x % p[j] == 0) {
                x /= p[j];
                c[j]++;
            }
        }
        var cp = c.map((v, i) => v ? p[i] : 0).filter(v => v);
        c = c.filter(v => v);
        if (c.length == 1) {
            console.log(Array(c[0]).fill(0).map((v, i) => cp[0] ** (i + 1)).join(' '));
            console.log(0);
        }
        else {
            let mark = {};
            let arr = [];
            for (let i = 0; i < c.length; i++) {
                let bit = Array(c.length).fill(0);
                bit[i] = 1;
                arr.push(bit);
                mark[bit.join('')] = 1;
                bit = Array(c.length).fill(0);
                bit[i] = 1;
                bit[(i + 1) % c.length] = 1;
                arr.push(bit);
                mark[bit.join('')] = 1;
            }
            let c2 = 2 ** c.length;
            while (arr.length < c2 - 1) {
                for (let i = 1; i < c2; i++) {
                    let bit = Array(c.length).fill(0);
                    for (let j = 0; j < c.length; j++)
                        bit[j] = i & (1 << j) ? 1 : 0;
                    if (mark[bit.join('')])
                        continue;
                    if (bit.some((v, i) => arr[arr.length - 1][i] == v)) {
                        arr.push(bit);
                        mark[bit.join('')] = 1;
                    }
                }
            }
            console.log(arr);
            console.log(0);
        }
    }
})();
Object.defineProperty(Object.prototype, '$k', {
    value: function () { return Object.keys(this); }
});
Object.defineProperty(Object.prototype, '$v', {
    value: function () { return Object.values(this); }
});
Object.defineProperty(Object.prototype, '$kv', {
    value: function () { return Object.entries(this); }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0); };
Array.prototype.uniq = function (fn) {
    var set = new Set();
    return this.filter(v => {
        var newValue = !set.has(fn ? fn(v) : v);
        set.add(fn ? fn(v) : v);
        return newValue;
    });
};
Array.prototype.toObj = function (fn) {
    return this.map(v => fn(v)).reduce((p, v) => {
        p[v[0]] = v[1];
        return p;
    }, {});
};

function mlt() { return readline().split(' ').map(x => parseInt(x)) }

function solv() {

    var inp = mlt()
    var x = inp[0]
    var y = inp[1]

    var s = mlt()

    var vis = {}
    for (var n = 0; n < x; n++)vis[s[n]] = (vis[s[n]] == null ? 1 : vis[s[n]] + 1)
    if (vis[y] == x) {
        print(0)
        return
    }
    else if (vis[x] >= 1) {
        print(1)
        return
    }
    var sm = 0;
    for (var n = 0; n < x; n++)sm += s[n] - y;
    if (sm == 0) {
        print(1);
    }
    else print(2)
}

var tc = 1;
tc = parseInt(readline());
while (tc--) solv()

"use strict";
var input = '';
var inputResolve;
var inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => {
    inputResolve();
});
(async () => {
    // var time = Date.now();
    await inputPromise;
    var inputs = input.split(/\r?\n/);
    var t = +inputs[0];
    for (let i = 0; i < t; i++) {
        var [n, x] = inputs[i * 2 + 1].split(' ').map(v => +v);
        var arr = inputs[i * 2 + 2].split(' ').map(v => +v);
        if (arr.every(v => v == x)) {
            console.log(0);
        }
        else if (arr.sum() == n * x) {
            console.log(1);
        }
        else {
            console.log(2);
        }
    }
})();
Object.defineProperty(Object.prototype, '$k', {
    value: function () { return Object.keys(this); }
});
Object.defineProperty(Object.prototype, '$v', {
    value: function () { return Object.values(this); }
});
Object.defineProperty(Object.prototype, '$kv', {
    value: function () { return Object.entries(this); }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0); };
Array.prototype.uniq = function (fn) {
    var set = new Set();
    return this.filter(v => {
        var newValue = !set.has(fn ? fn(v) : v);
        set.add(fn ? fn(v) : v);
        return newValue;
    });
};
Array.prototype.toObj = function (fn) {
    return this.map(v => fn(v)).reduce((p, v) => {
        p[v[0]] = v[1];
        return p;
    }, {});
};

"use strict";
var input = '';
var inputResolve;
var inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => {
    inputResolve();
});
(async () => {
    // var time = Date.now();
    await inputPromise;
    var inputs = input.split(/\r?\n/);
    var t = +inputs[0];
    for (let i = 0; i < t; i++) {
        var [n, x] = inputs[i * 2 + 1].split(' ').map(v => +v);
        var arr = inputs[i * 2 + 2].split(' ').map(v => +v);
        if (arr.every(v => v == x)) {
            console.log(0);
        }
        else if (arr.some(v => v == n) || arr.sum() == n * x) {
            console.log(1);
        }
        else {
            console.log(2);
        }
    }
    return;
    var p = [2];
    for (let i = 3; i < 1e5; i += 2) {
        let prime = true;
        for (let v of p) {
            if (v * v > i)
                break;
            if (i % v == 0) {
                prime = false;
                break;
            }
        }
        if (prime)
            p.push(i);
    }
    for (let i = 0; i < t; i++) {
        var x = +inputs[i + 1];
        var c = Array(p.length).fill(0);
        for (let j = 0;; j++) {
            if (p[j] > x)
                break;
            while (x % p[j] == 0) {
                x /= p[j];
                c[j]++;
            }
        }
        var cp = c.map((v, i) => v ? p[i] : 0).filter(v => v);
        c = c.filter(v => v);
        if (c.length == 1) {
            console.log(Array(c[0]).fill(0).map((v, i) => cp[0] ** (i + 1)).join(' '));
            console.log(0);
        }
        else {
            let mark = {};
            let arr = [];
            for (let i = 0; i < c.length; i++) {
                let bit = Array(c.length).fill(0);
                bit[i] = 1;
                arr.push(bit);
                mark[bit.join('')] = 1;
                bit = Array(c.length).fill(0);
                bit[i] = 1;
                bit[(i + 1) % c.length] = 1;
                arr.push(bit);
                mark[bit.join('')] = 1;
            }
            let c2 = 2 ** c.length;
            while (arr.length < c2 - 1) {
                for (let i = 1; i < c2; i++) {
                    let bit = Array(c.length).fill(0);
                    for (let j = 0; j < c.length; j++)
                        bit[j] = i & (1 << j) ? 1 : 0;
                    if (mark[bit.join('')])
                        continue;
                    if (bit.some((v, i) => arr[arr.length - 1][i] == v)) {
                        arr.push(bit);
                        mark[bit.join('')] = 1;
                    }
                }
            }
            console.log(arr);
            console.log(0);
        }
    }
})();
Object.defineProperty(Object.prototype, '$k', {
    value: function () { return Object.keys(this); }
});
Object.defineProperty(Object.prototype, '$v', {
    value: function () { return Object.values(this); }
});
Object.defineProperty(Object.prototype, '$kv', {
    value: function () { return Object.entries(this); }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0); };
Array.prototype.uniq = function (fn) {
    var set = new Set();
    return this.filter(v => {
        var newValue = !set.has(fn ? fn(v) : v);
        set.add(fn ? fn(v) : v);
        return newValue;
    });
};
Array.prototype.toObj = function (fn) {
    return this.map(v => fn(v)).reduce((p, v) => {
        p[v[0]] = v[1];
        return p;
    }, {});
};

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    C();
});

function readline() {
    return inputString[currentLine++];
}

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function C(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [n,x] = ti(readline().split(' '));
        let a = ti(readline().split(' '));

        let sum = 0;
        let f = true;
        for(let i = 0; i < n; i++){
            if(a[i] !== x)
                f = false;

            sum += a[i] - x;
        }

        if(f){
            console.log(0);
        }else if(sum === 0){
            console.log(1);
        }else{
            console.log(2);
        }
    }
}


var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let T = rn();
	while (T--) {
		let [a, b] = rna();

		if (a > b) {
			[a, b] = [b, a];
		}

		const k = b-a>>1;
		let ans = Math.min(a, b-a>>1);
		ans += a-ans>>1;

		console.log(ans);
	}
}

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0 ; i < t; i++){
		let [a, b] = nl.nums();
 		if (a * 3 >= b && b * 3 >= a) {
			ans.push(Math.trunc((a + b) / 4));
		} else {
			ans.push(Math.min(a, b));
		}
	}
	console.log(ans.join('\n'));
};

process.stdin.on('end', sol);

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main(inputString);
});

function log(message){
    if(process.env.NODE_ENV === "debug"){
        console.log(message);
    }
}

function main(fileContents) {//input lines as an array
    // console.log(fileContents);
    fileContents.splice(0,1);
    fileContents
        .map(solveLine)
        .forEach(x => console.log(x))
}

function solveLine(programmersAndMaths){
    const maths = parseInt(programmersAndMaths.split(" ")[0],10)
    const programmers = parseInt(programmersAndMaths.split(" ")[1],10)
    // console.log("xxxxx", maths, programmers, programmersAndMaths)

    if(programmers/3  > maths){
        return maths;
    }else if(maths/3 > programmers){
        return programmers
    }else{
        return Math.floor((maths+programmers)/4)
    }
}

// const rl = require('readline-sync');
// const { stdin: input, stdout: output } = require('process');

// //const rl = readline.createInterface({ input, output });
// const arrayJan=[]
// const t= parseInt(rl.question(''))
// for (let i=1;i<=t;i++) {
//     arrayJan.push(rl.question())
// }

// // const arrayStyle = [3876,387,4489,3]
// // const n = 122345
// arrayJan.map((n)=>{
// const nString = n.toString()
// const lastNumber = parseInt(nString[nString.length-1])
// const firstNumber = parseInt(nString[0])
// const evenInside = ()=>{
//     for (let i=0;i<nString.length;i++){
//         const intVersion = parseInt(nString[i])

//         if (intVersion%2===0) {return true}
//     }
//     return false
// }

// if (lastNumber%2===0) {console.log(0)}
// else if (firstNumber%2==0) {console.log(1)}
// else if (evenInside()) { console.log(2)}
// else {console.log(-1)}
// })

var readline = require("readline");

var input = [];

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

rl.on("line", function (cmd) {
    const str = cmd.trim().split(" ")
    input.push({a:str[0],b:str[1]})
});
rl.on("close", function (cmd) {
    for (let j=1;j<input.length;j++){
        const a = parseInt(input[j].a);
        const b = parseInt(input[j].b);
        const c = Math.trunc((a+b)/4)
        if (c<Math.min(a,b)) {console.log(c)}
        else {console.log(Math.min(a,b))}

    }
    process.exit(0);
  });

const { mainModule } = require("process");
var readline = require("readline");

var input = [];

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

rl.on("line", function (cmd) {
  input.push(cmd);
});

rl.on("close", function () {
  let t = +input[0] + 1;
  for (let i = 1; i < t; ++i) {
    let temp = input[i].split(" ").map((x) => +x);
    let min = Math.min(temp[0], temp[1]);
    let top = Math.floor((+temp[0] + +temp[1]) / 4);
    if (console.log(Math.min(top, min)) !== undefined) console.log(0);
  }
  process.exit(0);
});

process.stdin.setEncoding('utf-8')
const readline = require('readline')

const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    }
)

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve([a, b]) {
    const c = Math.floor((a + b) / 4)
    const d = Math.min(a, b)
    if (d >= c) {
        console.log(c)
    } else {
        console.log(d)
    }
}

function main() {
    for (let i = 0; i < inputArr.length; i++) solve(inputArr[i])
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var A = nextInt();
		var B = nextInt();
		var team = Math.min(A, B);
		A -= team;
		B -= team;
		var ok = 0;
		ok += Math.min(Math.floor(A / 2), team);
		ok += Math.min(Math.floor(B / 2), team);
		team -= ok;
		ok += Math.floor(team / 2);
		myout(ok);
	}
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [a, b] = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(a, b)
    }
    console.log(output.join('\n'))
// })()
})

function solve(a, b) {
    if (a > b) return solve(b, a)
    const d = b - a
    let ans = 0
    let x = Math.floor(d / 2)
    x = Math.min(a, x)
    a -= x
    b -= 3 * x
    ans += x
    ans += Math.floor(Math.min(a, b) / 2)
    return ans
    // return Math.min(a, Math.floor(b / 3))
}

n = readline();
while (n--) {
  s = readline().split(" ").sort((a, b) => a - b);
  a = +s[0];
  b = +s[1];
  print((a + Math.min(b, 3 * a)) >> 2);
}

/*
===== READ INPUT DATA START =====
=================================
*/

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  let min = Math.min(a, b);
  let max = Math.max(a, b);
  let result = 0;
  let value;

  while (min > 0 && max - min >= 3) {
    value = Math.min(
      min,
      Math.floor((max - min) / 3)
    );

    min -= value;
    max -= value * 3;
    result += value;
  }

  if (min > 0) {
    if (max - min >= 2 && min % 2 === 1) {
      result++;
    }

    result += Math.floor(min / 2);
  }

  console.log(result);
}

var t = parseInt(readline());
  function solve() {
    var inp = readline()
      .split(" ")
      .map((data) => +data);

    var a = inp[0];
    var b = inp[1];
    var ans = Math.min(Math.min(a, b), (a + b) / 4);
    return Math.floor(ans);
  }

  while (t--) {
    print(solve());
  }

var t = parseInt(readline());
  function solve() {
    var inp = readline()
      .split(" ")
      .map((data) => +data);

    var a = inp[0];
    var b = inp[1];
    var d = 0;

    if (a == b) {
      return (a + b) / 4;
    } else if (a > b) {
      d = a - b;
      a -= d;
      d /= 2;
      d = Math.min(a, d);
      a -= d;
      b -= d;
      d += (a + b) / 4;
      return d;
    } else {
      d = b - a;
      b -= d;
      d /= 2;
      d = Math.min(a, d);
      a -= d;
      b -= d;
      d += (a + b) / 4;
      return d;
    }
  }

  while (t--) {
    print(Math.floor(solve()));
  }

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline(){
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
   let t = readline();
    while(t > 0){
        let val = readline().split(" ").map(x => parseInt(x));
        let a = parseInt(val[0]);
        let b = parseInt(val[1]);
        if( a/3 > b){
            console.log(b);
        }else if(b/3 > a){
            console.log(a);
        }else{
            console.log(Math.floor((a + b)/4));
        }

            t--;
         }

}

let y = '';
process.stdin.on('data', c => y += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = y.split(EOL);
	var t = lines[0];
	for(i = 1; i <= t; i++){
	   	var k = lines[i].split(' ').map(Number);
        var a = k[0], b = k[1], d = 0;
        if(a == b){
            console.log(Math.floor((a + b) / 4));
        }else if(a > b){
            d = a - b;
            a -= d;
            d /= 2;
            d = Math.min(a, d);
            a -= d;
            b -= d;
            d += (a + b) / 4;
            console.log(Math.floor(d));
        }else{
            d = b - a;
            b -= d;
            d /= 2;
            d = Math.min(a, d);
            a -= d;
            b -= d;
            d += (a + b) / 4;
            console.log(Math.floor(d));
        }
	}
});

/*
===== READ INPUT DATA START =====
=================================
*/

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  let min = Math.min(a, b);
  let max = Math.max(a, b);
  let result = 0;
  let value;

  if (min * 3 <= max) {
    console.log(min);
    return;
  }

  if (max - min > 2) {
    value = Math.ceil((max - min) / 3);

    min -= value;
    max -= value * 3;
    result += value;
  }

  value = Math.floor(min / 2);
  result += value;

  if (min % 2 === 1 && max - value * 2 >= 3) {
    result++;
  }

  console.log(result);
}

/*
===== READ INPUT DATA START =====
=================================
*/

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  let min = Math.min(a, b);
  let max = Math.max(a, b);
  let value = Math.min(min, Math.floor((max - min) / 3));
  let result = 0;

  min -= value;
  max -= value * 3;
  result += value;

  if (min > 0) {
    if (max - min >= 3) {
      result++;
      min -= 1;
      max -= 3;
    }

    if (min % 2 === 1 && max - min >= 2) {
      result++;
    }

    result += Math.floor(min / 2);
  }

  console.log(result);
}

/*
===== READ INPUT DATA START =====
=================================
*/

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  const min = Math.min(a, b);
  const max = Math.max(a, b);
  let alternative1 = Math.floor(min / 2);
  let alternative2 = Math.min(min, Math.floor(max / 3));

  if ((max - alternative1 * 2) >= 3 && (min - alternative1 * 2) === 1) {
    alternative1++;
  }

  if ((max - alternative2 * 3) >= 2 && (min - alternative2) >= 2) {
    alternative2++;
  } else if ((max - alternative2 * 3) >= 3 && (min - alternative2) >= 1) {
    alternative2++;
  } else if ((max - alternative2 * 3) >= 1 && (min - alternative2) >= 3) {
    alternative2++;
  }

  console.log(Math.max(alternative1, alternative2));
}

/*
===== READ INPUT DATA START =====
=================================
*/

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  const min = Math.min(a, b);
  const max = Math.max(a, b);
  let alternative1 = Math.floor(min / 2);
  let alternative2 = Math.min(min, Math.floor(max / 3));

  if ((max - alternative1 * 2) >= 3 && (min - alternative1 * 2) === 1) {
    alternative1++;
  }

  if ((max - alternative2 * 3) >= 2 && (min - alternative2) >= 2) {
    alternative2++;
  } else if ((max - alternative2 * 3) >= 3 && (min - alternative2) >= 1) {
    alternative2++;
  }

  console.log(Math.max(alternative1, alternative2));
}

/*
===== READ INPUT DATA START =====
=================================
*/

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  const min = Math.min(a, b);
  const max = Math.max(a, b);
  let alternative1 = Math.floor(min / 2);
  let alternative2 = Math.min(min, Math.floor(max / 3));

  if ((max - alternative1 * 2) === 3 && (min - alternative1 * 2) === 1) {
    alternative1++;
  }

  if ((max - alternative2 * 3) % 3 > 1 && min - alternative2 > 0) {
    alternative2++;
  }

  console.log(Math.max(alternative1, alternative2));
}

/*
===== READ INPUT DATA START =====
=================================
*/

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  const min = Math.min(a, b);
  const max = Math.max(a, b);
  let alternative1 = Math.floor(min / 2);
  let alternative2 = Math.min(min, Math.floor(max / 3));

  if ((max - alternative1 * 2) === 3 && min - alternative1 > 0) {
    alternative1++;
  }

  if ((max - alternative2 * 3) % 3 > 1 && min - alternative2 > 0) {
    alternative2++;
  }

  console.log(Math.max(alternative1, alternative2));
}

/*
===== READ INPUT DATA START =====
=================================
*/

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  const min = Math.min(a, b);
  const max = Math.max(a, b);
  let alternative1 = Math.floor(min / 2);
  let alternative2 = Math.min(min, Math.floor(max / 3));

  if ((max - alternative2 * 3) % 3 > 1 && min - alternative2 > 0) {
    alternative2++;
  }

  console.log(Math.max(alternative1, alternative2));
}

/*
===== READ INPUT DATA START =====
=================================
*/

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  const min = Math.min(a, b);
  const max = Math.max(a, b);
  let result;

  result = Math.max(
    Math.floor(min / 2),
    Math.min(min, Math.floor(max / 3))
  );

  console.log(result);
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline(){
    return inputString[currentLine++];
}

function recursive(a,b){
     if( a == b){
            return Math.floor(a/2);
        }else{
            let div2, div3;
            div2 = Math.min(Math.floor(a/2),Math.floor(b/2));
            if(a > b){
                div3 = Math.min(Math.floor(a/3),Math.floor(b/1));
            }else{
                div3 = Math.min(Math.floor(a/1),Math.floor(b/3));

            }
            if(div2>= div3){
            let tempNum = div2*2;
               let tempA = a - tempNum ;
               let tempB = b - tempNum ;
            if(tempA > 0 && tempB > 0 && (tempA + tempB >=4)){
                 return div2+ recursive(tempA,tempB);
            }else{
                return div2;
            }
        }else{
            return div3;
        }
    }
}

function main() {
    let t = readline();
    while(t--){
        let val = readline().split(" ").map(x => parseInt(x));
        let a = parseInt(val[0]);
        let b = parseInt(val[1]);
         console.log(recursive(a,b));

    }

}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline(){
    return inputString[currentLine++];
}

function main() {
    let t = readline();
    while(t--){
        let val = readline().split(" ").map(x => parseInt(x));
        let a = parseInt(val[0]);
        let b = parseInt(val[1]);
        if( a == b){
            console.log(Math.floor(a/2));
        }else{

            let div2, div3;
            div2 = Math.min(Math.floor(a/2),Math.floor(b/2));
            if(a > b){
                div3 = Math.min(Math.floor(a/3),Math.floor(b/1));
            }else{
                div3 = Math.min(Math.floor(a/1),Math.floor(b/3));

            }
          if(div2 >= div3){
               let tempNum = div2*2;
               let tempA = a - tempNum ;
               let tempB = b - tempNum ;
               if(tempA > 0 && tempB > 0 && (tempA + tempB >=4)){
                 console.log(div2+ Math.floor((tempA + tempB)/4));
               }else{
                console.log(div2);
               }
          }else{
            console.log(div3);
          }
        }

    }

}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline(){
    return inputString[currentLine++];
}

function main() {
    let t = readline();
    while(t--){
        let val = readline().split(" ").map(x => parseInt(x));
        let a = parseInt(val[0]);
        let b = parseInt(val[1]);
        if( a == b){
            console.log(Math.floor(a/2));
        }else{

            let div2, div3;
            div2 = Math.min(Math.floor(a/2),Math.floor(b/2));
            if(a > b){
                div3 = Math.min(Math.floor(a/3),Math.floor(b/1));
            }else{
                div3 = Math.min(Math.floor(a/1),Math.floor(b/3));

            }
          if(div2 >= div3){
               let tempNum = div2*2;
               let tempA = a - tempNum ;
               let tempB = b - tempNum ;
               if(tempA > 0 && tempB > 0 && (tempA + tempB >=4)){
                 console.log(div2+1);
               }else{
                console.log(div2);
               }
          }else{
            console.log(div3);
          }
        }

    }

}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline(){
    return inputString[currentLine++];
}

function main() {
    let t = readline();
    while(t--){
        let val = readline().split(" ").map(x => parseInt(x));
        let a = parseInt(val[0]);
        let b = parseInt(val[1]);
        if( a == b){
            console.log(Math.floor(a/2));
        }else{

            let div2, div3;
            div2 = Math.min(Math.floor(a/2),Math.floor(b/2));
            if(a > b){
                div3 = Math.min(Math.floor(a/3),Math.floor(b/1));
            }else{
                div3 = Math.min(Math.floor(a/1),Math.floor(b/3));

            }
          if(div2 >= div3){
               let tempNum = div2 *2;
               let tempA = a - tempNum ;
               let tempB = b - tempNum ;
               if(tempA > 0 && tempB > 0 && (tempA + tempB >=4)){
                 console.log(div2+1);
               }else{
                console.log(div2);
               }
          }else{
            console.log(div3);
          }
        }

    }

}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline(){
    return inputString[currentLine++];
}

function main() {
    let t = readline();
    while(t--){
        let x = readline();
        let a = parseInt(x);
        let y = readline();
        let b = parseInt(y);
        if( a == b){
            console.log(Math.floor(a/2));
        }else{

            let div2, div3;
            div2 = Math.min(Math.floor(a/2),Math.floor(b/2));
            if(a > b){
                div3 = Math.min(Math.floor(a/3),Math.floor(b/1));
            }else{
                div3 = Math.min(Math.floor(a/1),Math.floor(b/3));

            }
          if(div2 >= div3){
               let tempNum = div2 *2;
               let tempA = a - tempNum ;
               let tempB = b - tempNum ;
               if(tempA > 0 && tempB > 0 && (tempA + tempB >=4)){
                 console.log(div2+1);
               }else{
                console.log(div2);
               }
          }else{
            console.log(div3);
          }
        }

    }

}

let y = '';
process.stdin.on('data', c => y += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = y.split(EOL);
	var t = lines[0];
	for(i = 1; i <= t; i++){
	   	var k = lines[i].split(' ').map(Number);
        var a = k[0], b = k[1], d = 0;
        if(a == b){
            console.log(Math.floor((a + b) / 4));
        }else if(a > b){
            d = a - b;
            a -= d;
            d /= 2;
            d = Math.min(a, d);
            a -= d;
            b -= d;
            d += Math.floor((a + b) / 4);
            console.log(Math.ceil(d));
        }else{
            d = b - a;
            b -= d;
            d /= 2;
            d = Math.min(a, d);
            a -= d;
            b -= d;
            d += Math.floor((a + b) / 4);
            console.log(Math.ceil(d));
        }
	}
});

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0 ; i < t; i++){
		let [a, b] = nl.nums();
 		if (a * 4 > b && b * 4 > a) {
			ans.push(Math.trunc((a + b) / 4));
		} else {
			ans.push(Math.min(a, b));
		}
	}
	console.log(ans.join('\n'));
};

process.stdin.on('end', sol);

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0 ; i < t; i++){
		let [a, b] = nl.nums();
 		if (a * 4 >= b && b * 4 >= a) {
			ans.push(Math.trunc((a + b) / 4));
		} else {
			ans.push(Math.min(a, b));
		}
	}
	console.log(ans.join('\n'));
};

process.stdin.on('end', sol);

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main(inputString);
});

function log(message){
    if(process.env.NODE_ENV === "debug"){
        console.log(message);
    }
}

function main(fileContents) {//input lines as an array
    // console.log(fileContents);
    fileContents.splice(0,1);
    fileContents
        .map(solveLine)
        .forEach(x => console.log(x))
}

function solveLine(programmersAndMaths){
    const maths = parseInt(programmersAndMaths.split(" ")[0],10)
    const programmers = parseInt(programmersAndMaths.split(" ")[1],10)
    // console.log("xxxxx", maths, programmers, programmersAndMaths)

    if(programmers/3  > maths){
        return maths;
    }else if(maths/3 > programmers){
        return programmers
    }else{
        return Math.ceil((maths+programmers)/4)
    }
}