import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < t; i++) { sb.append(getString(sc.nextLong(), sc.nextLong())).append("\n"); } System.out.print(sb); } static StringBuilder getString(long a, long b) { ArrayList list = new ArrayList<>(); while (a < b) { if (a * 2 <= b) { list.add(a); a *= 2; continue; } ArrayList tmp = new ArrayList<>(); for (long i = 2; i <= Math.sqrt(a) && a + i <= b; i++) { if (a % i == 0) { if (a + a / i <= b) { tmp.add(a / i); break; } else { tmp.add(i); } } } if (tmp.size() == 0) { list.add(1L); a++; } else { list.add(tmp.get(tmp.size() - 1)); a += tmp.get(tmp.size() - 1); } } StringBuilder sb = new StringBuilder(); sb.append(list.size()).append("\n"); for (int i = 0; i < list.size(); i++) { if (i > 0) { sb.append(" "); } sb.append(list.get(i)); } return sb; } }