var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input.split('\n').forEach(function(line) {
  if (line !== '') {
    var nums = line.split(' ').map(Number);
    while (nums[0] !== 0 && nums[1] !== 0) {
      var l = Math.max(nums[0], nums[1]);
      var s = Math.min(nums[0], nums[1]);
      nums[0] = s;
      nums[1] = l % s;
    }
    console.log(nums[0]);
  }
});