From 1fdb09016641e02a7cc0a5046a66131b3f46ab49 Mon Sep 17 00:00:00 2001 From: Aurelien FOCURET Date: Mon, 16 Jun 2025 16:41:45 +0200 Subject: [PATCH 01/10] [ES|QL] Ability to use non-constant expression for commandOptions. --- .../plugin/esql/src/main/antlr/EsqlBaseParser.g4 | 2 +- .../xpack/esql/parser/EsqlBaseParser.interp | 2 +- .../xpack/esql/parser/EsqlBaseParser.java | 8 ++++---- .../xpack/esql/parser/LogicalPlanBuilder.java | 15 ++++++++------- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4 b/x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4 index ce097bbd9e578..0aeeda87ac2fa 100644 --- a/x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4 +++ b/x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4 @@ -232,7 +232,7 @@ commandOptions ; commandOption - : identifier ASSIGN constant + : identifier ASSIGN primaryExpression ; explainCommand diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp index 41339c4c79029..9fc261a72c593 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp @@ -368,4 +368,4 @@ joinPredicate atn: -[4, 1, 139, 781, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 2, 66, 7, 66, 2, 67, 7, 67, 2, 68, 7, 68, 2, 69, 7, 69, 2, 70, 7, 70, 2, 71, 7, 71, 2, 72, 7, 72, 2, 73, 7, 73, 2, 74, 7, 74, 2, 75, 7, 75, 2, 76, 7, 76, 2, 77, 7, 77, 2, 78, 7, 78, 2, 79, 7, 79, 2, 80, 7, 80, 2, 81, 7, 81, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 174, 8, 1, 10, 1, 12, 1, 177, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 185, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 216, 8, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 5, 7, 229, 8, 7, 10, 7, 12, 7, 232, 9, 7, 1, 8, 1, 8, 1, 8, 3, 8, 237, 8, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 5, 9, 244, 8, 9, 10, 9, 12, 9, 247, 9, 9, 1, 10, 1, 10, 1, 10, 3, 10, 252, 8, 10, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 5, 13, 263, 8, 13, 10, 13, 12, 13, 266, 9, 13, 1, 13, 3, 13, 269, 8, 13, 1, 14, 1, 14, 1, 14, 3, 14, 274, 8, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 280, 8, 14, 3, 14, 282, 8, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 5, 18, 294, 8, 18, 10, 18, 12, 18, 297, 9, 18, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 3, 20, 304, 8, 20, 1, 20, 1, 20, 3, 20, 308, 8, 20, 1, 21, 1, 21, 1, 21, 5, 21, 313, 8, 21, 10, 21, 12, 21, 316, 9, 21, 1, 22, 1, 22, 1, 22, 3, 22, 321, 8, 22, 1, 23, 1, 23, 1, 23, 5, 23, 326, 8, 23, 10, 23, 12, 23, 329, 9, 23, 1, 24, 1, 24, 1, 24, 5, 24, 334, 8, 24, 10, 24, 12, 24, 337, 9, 24, 1, 25, 1, 25, 1, 25, 5, 25, 342, 8, 25, 10, 25, 12, 25, 345, 9, 25, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 3, 27, 352, 8, 27, 1, 28, 1, 28, 3, 28, 356, 8, 28, 1, 29, 1, 29, 3, 29, 360, 8, 29, 1, 30, 1, 30, 1, 30, 3, 30, 365, 8, 30, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 5, 32, 374, 8, 32, 10, 32, 12, 32, 377, 9, 32, 1, 33, 1, 33, 3, 33, 381, 8, 33, 1, 33, 1, 33, 3, 33, 385, 8, 33, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 397, 8, 36, 10, 36, 12, 36, 400, 9, 36, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 3, 37, 410, 8, 37, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 416, 8, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 5, 41, 428, 8, 41, 10, 41, 12, 41, 431, 9, 41, 1, 42, 1, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 44, 1, 44, 1, 44, 1, 44, 1, 45, 1, 45, 1, 45, 1, 46, 1, 46, 1, 46, 1, 46, 3, 46, 451, 8, 46, 1, 46, 1, 46, 1, 46, 1, 46, 5, 46, 457, 8, 46, 10, 46, 12, 46, 460, 9, 46, 3, 46, 462, 8, 46, 1, 47, 1, 47, 1, 47, 3, 47, 467, 8, 47, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 1, 49, 1, 49, 3, 49, 480, 8, 49, 1, 50, 1, 50, 1, 50, 1, 50, 3, 50, 486, 8, 50, 1, 50, 1, 50, 1, 50, 1, 50, 1, 50, 3, 50, 493, 8, 50, 1, 51, 1, 51, 1, 51, 1, 52, 1, 52, 1, 52, 1, 53, 4, 53, 502, 8, 53, 11, 53, 12, 53, 503, 1, 54, 1, 54, 1, 54, 1, 54, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 5, 55, 516, 8, 55, 10, 55, 12, 55, 519, 9, 55, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 3, 56, 530, 8, 56, 1, 57, 1, 57, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 3, 58, 540, 8, 58, 1, 59, 1, 59, 1, 59, 1, 59, 3, 59, 546, 8, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 60, 1, 60, 1, 60, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 3, 61, 562, 8, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 5, 61, 569, 8, 61, 10, 61, 12, 61, 572, 9, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 3, 61, 579, 8, 61, 1, 61, 1, 61, 1, 61, 3, 61, 584, 8, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 5, 61, 592, 8, 61, 10, 61, 12, 61, 595, 9, 61, 1, 62, 1, 62, 3, 62, 599, 8, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 3, 62, 606, 8, 62, 1, 62, 1, 62, 1, 62, 3, 62, 611, 8, 62, 1, 63, 1, 63, 1, 63, 3, 63, 616, 8, 63, 1, 63, 1, 63, 1, 63, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 3, 64, 626, 8, 64, 1, 65, 1, 65, 1, 65, 1, 65, 3, 65, 632, 8, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 5, 65, 640, 8, 65, 10, 65, 12, 65, 643, 9, 65, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 3, 66, 653, 8, 66, 1, 66, 1, 66, 1, 66, 5, 66, 658, 8, 66, 10, 66, 12, 66, 661, 9, 66, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 5, 67, 669, 8, 67, 10, 67, 12, 67, 672, 9, 67, 1, 67, 1, 67, 3, 67, 676, 8, 67, 3, 67, 678, 8, 67, 1, 67, 1, 67, 1, 68, 1, 68, 1, 69, 1, 69, 1, 69, 1, 69, 5, 69, 688, 8, 69, 10, 69, 12, 69, 691, 9, 69, 1, 69, 1, 69, 1, 70, 1, 70, 1, 70, 1, 70, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 5, 71, 712, 8, 71, 10, 71, 12, 71, 715, 9, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 5, 71, 723, 8, 71, 10, 71, 12, 71, 726, 9, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 5, 71, 734, 8, 71, 10, 71, 12, 71, 737, 9, 71, 1, 71, 1, 71, 3, 71, 741, 8, 71, 1, 72, 1, 72, 1, 73, 1, 73, 3, 73, 747, 8, 73, 1, 74, 3, 74, 750, 8, 74, 1, 74, 1, 74, 1, 75, 3, 75, 755, 8, 75, 1, 75, 1, 75, 1, 76, 1, 76, 1, 77, 1, 77, 1, 78, 1, 78, 1, 78, 1, 78, 1, 78, 1, 79, 1, 79, 1, 80, 1, 80, 1, 80, 1, 80, 5, 80, 774, 8, 80, 10, 80, 12, 80, 777, 9, 80, 1, 81, 1, 81, 1, 81, 0, 5, 2, 110, 122, 130, 132, 82, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 0, 9, 2, 0, 53, 53, 107, 107, 1, 0, 101, 102, 2, 0, 57, 57, 63, 63, 2, 0, 66, 66, 69, 69, 1, 0, 87, 88, 1, 0, 89, 91, 2, 0, 65, 65, 78, 78, 2, 0, 80, 80, 82, 86, 2, 0, 22, 22, 24, 25, 816, 0, 164, 1, 0, 0, 0, 2, 167, 1, 0, 0, 0, 4, 184, 1, 0, 0, 0, 6, 215, 1, 0, 0, 0, 8, 217, 1, 0, 0, 0, 10, 220, 1, 0, 0, 0, 12, 222, 1, 0, 0, 0, 14, 225, 1, 0, 0, 0, 16, 236, 1, 0, 0, 0, 18, 240, 1, 0, 0, 0, 20, 248, 1, 0, 0, 0, 22, 253, 1, 0, 0, 0, 24, 256, 1, 0, 0, 0, 26, 259, 1, 0, 0, 0, 28, 281, 1, 0, 0, 0, 30, 283, 1, 0, 0, 0, 32, 285, 1, 0, 0, 0, 34, 287, 1, 0, 0, 0, 36, 289, 1, 0, 0, 0, 38, 298, 1, 0, 0, 0, 40, 301, 1, 0, 0, 0, 42, 309, 1, 0, 0, 0, 44, 317, 1, 0, 0, 0, 46, 322, 1, 0, 0, 0, 48, 330, 1, 0, 0, 0, 50, 338, 1, 0, 0, 0, 52, 346, 1, 0, 0, 0, 54, 351, 1, 0, 0, 0, 56, 355, 1, 0, 0, 0, 58, 359, 1, 0, 0, 0, 60, 364, 1, 0, 0, 0, 62, 366, 1, 0, 0, 0, 64, 369, 1, 0, 0, 0, 66, 378, 1, 0, 0, 0, 68, 386, 1, 0, 0, 0, 70, 389, 1, 0, 0, 0, 72, 392, 1, 0, 0, 0, 74, 409, 1, 0, 0, 0, 76, 411, 1, 0, 0, 0, 78, 417, 1, 0, 0, 0, 80, 421, 1, 0, 0, 0, 82, 424, 1, 0, 0, 0, 84, 432, 1, 0, 0, 0, 86, 436, 1, 0, 0, 0, 88, 439, 1, 0, 0, 0, 90, 443, 1, 0, 0, 0, 92, 446, 1, 0, 0, 0, 94, 466, 1, 0, 0, 0, 96, 470, 1, 0, 0, 0, 98, 475, 1, 0, 0, 0, 100, 481, 1, 0, 0, 0, 102, 494, 1, 0, 0, 0, 104, 497, 1, 0, 0, 0, 106, 501, 1, 0, 0, 0, 108, 505, 1, 0, 0, 0, 110, 509, 1, 0, 0, 0, 112, 529, 1, 0, 0, 0, 114, 531, 1, 0, 0, 0, 116, 533, 1, 0, 0, 0, 118, 541, 1, 0, 0, 0, 120, 551, 1, 0, 0, 0, 122, 583, 1, 0, 0, 0, 124, 610, 1, 0, 0, 0, 126, 612, 1, 0, 0, 0, 128, 625, 1, 0, 0, 0, 130, 631, 1, 0, 0, 0, 132, 652, 1, 0, 0, 0, 134, 662, 1, 0, 0, 0, 136, 681, 1, 0, 0, 0, 138, 683, 1, 0, 0, 0, 140, 694, 1, 0, 0, 0, 142, 740, 1, 0, 0, 0, 144, 742, 1, 0, 0, 0, 146, 746, 1, 0, 0, 0, 148, 749, 1, 0, 0, 0, 150, 754, 1, 0, 0, 0, 152, 758, 1, 0, 0, 0, 154, 760, 1, 0, 0, 0, 156, 762, 1, 0, 0, 0, 158, 767, 1, 0, 0, 0, 160, 769, 1, 0, 0, 0, 162, 778, 1, 0, 0, 0, 164, 165, 3, 2, 1, 0, 165, 166, 5, 0, 0, 1, 166, 1, 1, 0, 0, 0, 167, 168, 6, 1, -1, 0, 168, 169, 3, 4, 2, 0, 169, 175, 1, 0, 0, 0, 170, 171, 10, 1, 0, 0, 171, 172, 5, 52, 0, 0, 172, 174, 3, 6, 3, 0, 173, 170, 1, 0, 0, 0, 174, 177, 1, 0, 0, 0, 175, 173, 1, 0, 0, 0, 175, 176, 1, 0, 0, 0, 176, 3, 1, 0, 0, 0, 177, 175, 1, 0, 0, 0, 178, 185, 3, 86, 43, 0, 179, 185, 3, 22, 11, 0, 180, 185, 3, 12, 6, 0, 181, 185, 3, 90, 45, 0, 182, 183, 4, 2, 1, 0, 183, 185, 3, 24, 12, 0, 184, 178, 1, 0, 0, 0, 184, 179, 1, 0, 0, 0, 184, 180, 1, 0, 0, 0, 184, 181, 1, 0, 0, 0, 184, 182, 1, 0, 0, 0, 185, 5, 1, 0, 0, 0, 186, 216, 3, 38, 19, 0, 187, 216, 3, 8, 4, 0, 188, 216, 3, 68, 34, 0, 189, 216, 3, 62, 31, 0, 190, 216, 3, 40, 20, 0, 191, 216, 3, 64, 32, 0, 192, 216, 3, 70, 35, 0, 193, 216, 3, 72, 36, 0, 194, 216, 3, 76, 38, 0, 195, 216, 3, 78, 39, 0, 196, 216, 3, 92, 46, 0, 197, 216, 3, 80, 40, 0, 198, 216, 3, 156, 78, 0, 199, 216, 3, 100, 50, 0, 200, 216, 3, 118, 59, 0, 201, 202, 4, 3, 2, 0, 202, 216, 3, 98, 49, 0, 203, 204, 4, 3, 3, 0, 204, 216, 3, 96, 48, 0, 205, 206, 4, 3, 4, 0, 206, 216, 3, 102, 51, 0, 207, 208, 4, 3, 5, 0, 208, 216, 3, 104, 52, 0, 209, 210, 4, 3, 6, 0, 210, 216, 3, 116, 58, 0, 211, 212, 4, 3, 7, 0, 212, 216, 3, 114, 57, 0, 213, 214, 4, 3, 8, 0, 214, 216, 3, 120, 60, 0, 215, 186, 1, 0, 0, 0, 215, 187, 1, 0, 0, 0, 215, 188, 1, 0, 0, 0, 215, 189, 1, 0, 0, 0, 215, 190, 1, 0, 0, 0, 215, 191, 1, 0, 0, 0, 215, 192, 1, 0, 0, 0, 215, 193, 1, 0, 0, 0, 215, 194, 1, 0, 0, 0, 215, 195, 1, 0, 0, 0, 215, 196, 1, 0, 0, 0, 215, 197, 1, 0, 0, 0, 215, 198, 1, 0, 0, 0, 215, 199, 1, 0, 0, 0, 215, 200, 1, 0, 0, 0, 215, 201, 1, 0, 0, 0, 215, 203, 1, 0, 0, 0, 215, 205, 1, 0, 0, 0, 215, 207, 1, 0, 0, 0, 215, 209, 1, 0, 0, 0, 215, 211, 1, 0, 0, 0, 215, 213, 1, 0, 0, 0, 216, 7, 1, 0, 0, 0, 217, 218, 5, 15, 0, 0, 218, 219, 3, 122, 61, 0, 219, 9, 1, 0, 0, 0, 220, 221, 3, 52, 26, 0, 221, 11, 1, 0, 0, 0, 222, 223, 5, 12, 0, 0, 223, 224, 3, 14, 7, 0, 224, 13, 1, 0, 0, 0, 225, 230, 3, 16, 8, 0, 226, 227, 5, 62, 0, 0, 227, 229, 3, 16, 8, 0, 228, 226, 1, 0, 0, 0, 229, 232, 1, 0, 0, 0, 230, 228, 1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 15, 1, 0, 0, 0, 232, 230, 1, 0, 0, 0, 233, 234, 3, 46, 23, 0, 234, 235, 5, 58, 0, 0, 235, 237, 1, 0, 0, 0, 236, 233, 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 238, 1, 0, 0, 0, 238, 239, 3, 122, 61, 0, 239, 17, 1, 0, 0, 0, 240, 245, 3, 20, 10, 0, 241, 242, 5, 62, 0, 0, 242, 244, 3, 20, 10, 0, 243, 241, 1, 0, 0, 0, 244, 247, 1, 0, 0, 0, 245, 243, 1, 0, 0, 0, 245, 246, 1, 0, 0, 0, 246, 19, 1, 0, 0, 0, 247, 245, 1, 0, 0, 0, 248, 251, 3, 46, 23, 0, 249, 250, 5, 58, 0, 0, 250, 252, 3, 122, 61, 0, 251, 249, 1, 0, 0, 0, 251, 252, 1, 0, 0, 0, 252, 21, 1, 0, 0, 0, 253, 254, 5, 19, 0, 0, 254, 255, 3, 26, 13, 0, 255, 23, 1, 0, 0, 0, 256, 257, 5, 20, 0, 0, 257, 258, 3, 26, 13, 0, 258, 25, 1, 0, 0, 0, 259, 264, 3, 28, 14, 0, 260, 261, 5, 62, 0, 0, 261, 263, 3, 28, 14, 0, 262, 260, 1, 0, 0, 0, 263, 266, 1, 0, 0, 0, 264, 262, 1, 0, 0, 0, 264, 265, 1, 0, 0, 0, 265, 268, 1, 0, 0, 0, 266, 264, 1, 0, 0, 0, 267, 269, 3, 36, 18, 0, 268, 267, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, 27, 1, 0, 0, 0, 270, 271, 3, 30, 15, 0, 271, 272, 5, 61, 0, 0, 272, 274, 1, 0, 0, 0, 273, 270, 1, 0, 0, 0, 273, 274, 1, 0, 0, 0, 274, 275, 1, 0, 0, 0, 275, 282, 3, 34, 17, 0, 276, 279, 3, 34, 17, 0, 277, 278, 5, 60, 0, 0, 278, 280, 3, 32, 16, 0, 279, 277, 1, 0, 0, 0, 279, 280, 1, 0, 0, 0, 280, 282, 1, 0, 0, 0, 281, 273, 1, 0, 0, 0, 281, 276, 1, 0, 0, 0, 282, 29, 1, 0, 0, 0, 283, 284, 7, 0, 0, 0, 284, 31, 1, 0, 0, 0, 285, 286, 7, 0, 0, 0, 286, 33, 1, 0, 0, 0, 287, 288, 7, 0, 0, 0, 288, 35, 1, 0, 0, 0, 289, 290, 5, 106, 0, 0, 290, 295, 5, 107, 0, 0, 291, 292, 5, 62, 0, 0, 292, 294, 5, 107, 0, 0, 293, 291, 1, 0, 0, 0, 294, 297, 1, 0, 0, 0, 295, 293, 1, 0, 0, 0, 295, 296, 1, 0, 0, 0, 296, 37, 1, 0, 0, 0, 297, 295, 1, 0, 0, 0, 298, 299, 5, 9, 0, 0, 299, 300, 3, 14, 7, 0, 300, 39, 1, 0, 0, 0, 301, 303, 5, 14, 0, 0, 302, 304, 3, 42, 21, 0, 303, 302, 1, 0, 0, 0, 303, 304, 1, 0, 0, 0, 304, 307, 1, 0, 0, 0, 305, 306, 5, 59, 0, 0, 306, 308, 3, 14, 7, 0, 307, 305, 1, 0, 0, 0, 307, 308, 1, 0, 0, 0, 308, 41, 1, 0, 0, 0, 309, 314, 3, 44, 22, 0, 310, 311, 5, 62, 0, 0, 311, 313, 3, 44, 22, 0, 312, 310, 1, 0, 0, 0, 313, 316, 1, 0, 0, 0, 314, 312, 1, 0, 0, 0, 314, 315, 1, 0, 0, 0, 315, 43, 1, 0, 0, 0, 316, 314, 1, 0, 0, 0, 317, 320, 3, 16, 8, 0, 318, 319, 5, 15, 0, 0, 319, 321, 3, 122, 61, 0, 320, 318, 1, 0, 0, 0, 320, 321, 1, 0, 0, 0, 321, 45, 1, 0, 0, 0, 322, 327, 3, 60, 30, 0, 323, 324, 5, 64, 0, 0, 324, 326, 3, 60, 30, 0, 325, 323, 1, 0, 0, 0, 326, 329, 1, 0, 0, 0, 327, 325, 1, 0, 0, 0, 327, 328, 1, 0, 0, 0, 328, 47, 1, 0, 0, 0, 329, 327, 1, 0, 0, 0, 330, 335, 3, 54, 27, 0, 331, 332, 5, 64, 0, 0, 332, 334, 3, 54, 27, 0, 333, 331, 1, 0, 0, 0, 334, 337, 1, 0, 0, 0, 335, 333, 1, 0, 0, 0, 335, 336, 1, 0, 0, 0, 336, 49, 1, 0, 0, 0, 337, 335, 1, 0, 0, 0, 338, 343, 3, 48, 24, 0, 339, 340, 5, 62, 0, 0, 340, 342, 3, 48, 24, 0, 341, 339, 1, 0, 0, 0, 342, 345, 1, 0, 0, 0, 343, 341, 1, 0, 0, 0, 343, 344, 1, 0, 0, 0, 344, 51, 1, 0, 0, 0, 345, 343, 1, 0, 0, 0, 346, 347, 7, 1, 0, 0, 347, 53, 1, 0, 0, 0, 348, 352, 5, 128, 0, 0, 349, 352, 3, 56, 28, 0, 350, 352, 3, 58, 29, 0, 351, 348, 1, 0, 0, 0, 351, 349, 1, 0, 0, 0, 351, 350, 1, 0, 0, 0, 352, 55, 1, 0, 0, 0, 353, 356, 5, 76, 0, 0, 354, 356, 5, 95, 0, 0, 355, 353, 1, 0, 0, 0, 355, 354, 1, 0, 0, 0, 356, 57, 1, 0, 0, 0, 357, 360, 5, 94, 0, 0, 358, 360, 5, 96, 0, 0, 359, 357, 1, 0, 0, 0, 359, 358, 1, 0, 0, 0, 360, 59, 1, 0, 0, 0, 361, 365, 3, 52, 26, 0, 362, 365, 3, 56, 28, 0, 363, 365, 3, 58, 29, 0, 364, 361, 1, 0, 0, 0, 364, 362, 1, 0, 0, 0, 364, 363, 1, 0, 0, 0, 365, 61, 1, 0, 0, 0, 366, 367, 5, 11, 0, 0, 367, 368, 3, 142, 71, 0, 368, 63, 1, 0, 0, 0, 369, 370, 5, 13, 0, 0, 370, 375, 3, 66, 33, 0, 371, 372, 5, 62, 0, 0, 372, 374, 3, 66, 33, 0, 373, 371, 1, 0, 0, 0, 374, 377, 1, 0, 0, 0, 375, 373, 1, 0, 0, 0, 375, 376, 1, 0, 0, 0, 376, 65, 1, 0, 0, 0, 377, 375, 1, 0, 0, 0, 378, 380, 3, 122, 61, 0, 379, 381, 7, 2, 0, 0, 380, 379, 1, 0, 0, 0, 380, 381, 1, 0, 0, 0, 381, 384, 1, 0, 0, 0, 382, 383, 5, 73, 0, 0, 383, 385, 7, 3, 0, 0, 384, 382, 1, 0, 0, 0, 384, 385, 1, 0, 0, 0, 385, 67, 1, 0, 0, 0, 386, 387, 5, 29, 0, 0, 387, 388, 3, 50, 25, 0, 388, 69, 1, 0, 0, 0, 389, 390, 5, 28, 0, 0, 390, 391, 3, 50, 25, 0, 391, 71, 1, 0, 0, 0, 392, 393, 5, 32, 0, 0, 393, 398, 3, 74, 37, 0, 394, 395, 5, 62, 0, 0, 395, 397, 3, 74, 37, 0, 396, 394, 1, 0, 0, 0, 397, 400, 1, 0, 0, 0, 398, 396, 1, 0, 0, 0, 398, 399, 1, 0, 0, 0, 399, 73, 1, 0, 0, 0, 400, 398, 1, 0, 0, 0, 401, 402, 3, 48, 24, 0, 402, 403, 5, 132, 0, 0, 403, 404, 3, 48, 24, 0, 404, 410, 1, 0, 0, 0, 405, 406, 3, 48, 24, 0, 406, 407, 5, 58, 0, 0, 407, 408, 3, 48, 24, 0, 408, 410, 1, 0, 0, 0, 409, 401, 1, 0, 0, 0, 409, 405, 1, 0, 0, 0, 410, 75, 1, 0, 0, 0, 411, 412, 5, 8, 0, 0, 412, 413, 3, 132, 66, 0, 413, 415, 3, 152, 76, 0, 414, 416, 3, 82, 41, 0, 415, 414, 1, 0, 0, 0, 415, 416, 1, 0, 0, 0, 416, 77, 1, 0, 0, 0, 417, 418, 5, 10, 0, 0, 418, 419, 3, 132, 66, 0, 419, 420, 3, 152, 76, 0, 420, 79, 1, 0, 0, 0, 421, 422, 5, 27, 0, 0, 422, 423, 3, 46, 23, 0, 423, 81, 1, 0, 0, 0, 424, 429, 3, 84, 42, 0, 425, 426, 5, 62, 0, 0, 426, 428, 3, 84, 42, 0, 427, 425, 1, 0, 0, 0, 428, 431, 1, 0, 0, 0, 429, 427, 1, 0, 0, 0, 429, 430, 1, 0, 0, 0, 430, 83, 1, 0, 0, 0, 431, 429, 1, 0, 0, 0, 432, 433, 3, 52, 26, 0, 433, 434, 5, 58, 0, 0, 434, 435, 3, 142, 71, 0, 435, 85, 1, 0, 0, 0, 436, 437, 5, 6, 0, 0, 437, 438, 3, 88, 44, 0, 438, 87, 1, 0, 0, 0, 439, 440, 5, 97, 0, 0, 440, 441, 3, 2, 1, 0, 441, 442, 5, 98, 0, 0, 442, 89, 1, 0, 0, 0, 443, 444, 5, 33, 0, 0, 444, 445, 5, 136, 0, 0, 445, 91, 1, 0, 0, 0, 446, 447, 5, 5, 0, 0, 447, 450, 5, 38, 0, 0, 448, 449, 5, 74, 0, 0, 449, 451, 3, 48, 24, 0, 450, 448, 1, 0, 0, 0, 450, 451, 1, 0, 0, 0, 451, 461, 1, 0, 0, 0, 452, 453, 5, 79, 0, 0, 453, 458, 3, 94, 47, 0, 454, 455, 5, 62, 0, 0, 455, 457, 3, 94, 47, 0, 456, 454, 1, 0, 0, 0, 457, 460, 1, 0, 0, 0, 458, 456, 1, 0, 0, 0, 458, 459, 1, 0, 0, 0, 459, 462, 1, 0, 0, 0, 460, 458, 1, 0, 0, 0, 461, 452, 1, 0, 0, 0, 461, 462, 1, 0, 0, 0, 462, 93, 1, 0, 0, 0, 463, 464, 3, 48, 24, 0, 464, 465, 5, 58, 0, 0, 465, 467, 1, 0, 0, 0, 466, 463, 1, 0, 0, 0, 466, 467, 1, 0, 0, 0, 467, 468, 1, 0, 0, 0, 468, 469, 3, 48, 24, 0, 469, 95, 1, 0, 0, 0, 470, 471, 5, 26, 0, 0, 471, 472, 3, 28, 14, 0, 472, 473, 5, 74, 0, 0, 473, 474, 3, 50, 25, 0, 474, 97, 1, 0, 0, 0, 475, 476, 5, 16, 0, 0, 476, 479, 3, 42, 21, 0, 477, 478, 5, 59, 0, 0, 478, 480, 3, 14, 7, 0, 479, 477, 1, 0, 0, 0, 479, 480, 1, 0, 0, 0, 480, 99, 1, 0, 0, 0, 481, 482, 5, 4, 0, 0, 482, 485, 3, 46, 23, 0, 483, 484, 5, 74, 0, 0, 484, 486, 3, 46, 23, 0, 485, 483, 1, 0, 0, 0, 485, 486, 1, 0, 0, 0, 486, 492, 1, 0, 0, 0, 487, 488, 5, 132, 0, 0, 488, 489, 3, 46, 23, 0, 489, 490, 5, 62, 0, 0, 490, 491, 3, 46, 23, 0, 491, 493, 1, 0, 0, 0, 492, 487, 1, 0, 0, 0, 492, 493, 1, 0, 0, 0, 493, 101, 1, 0, 0, 0, 494, 495, 5, 30, 0, 0, 495, 496, 3, 50, 25, 0, 496, 103, 1, 0, 0, 0, 497, 498, 5, 21, 0, 0, 498, 499, 3, 106, 53, 0, 499, 105, 1, 0, 0, 0, 500, 502, 3, 108, 54, 0, 501, 500, 1, 0, 0, 0, 502, 503, 1, 0, 0, 0, 503, 501, 1, 0, 0, 0, 503, 504, 1, 0, 0, 0, 504, 107, 1, 0, 0, 0, 505, 506, 5, 99, 0, 0, 506, 507, 3, 110, 55, 0, 507, 508, 5, 100, 0, 0, 508, 109, 1, 0, 0, 0, 509, 510, 6, 55, -1, 0, 510, 511, 3, 112, 56, 0, 511, 517, 1, 0, 0, 0, 512, 513, 10, 1, 0, 0, 513, 514, 5, 52, 0, 0, 514, 516, 3, 112, 56, 0, 515, 512, 1, 0, 0, 0, 516, 519, 1, 0, 0, 0, 517, 515, 1, 0, 0, 0, 517, 518, 1, 0, 0, 0, 518, 111, 1, 0, 0, 0, 519, 517, 1, 0, 0, 0, 520, 530, 3, 38, 19, 0, 521, 530, 3, 8, 4, 0, 522, 530, 3, 62, 31, 0, 523, 530, 3, 40, 20, 0, 524, 530, 3, 64, 32, 0, 525, 530, 3, 76, 38, 0, 526, 530, 3, 100, 50, 0, 527, 530, 3, 118, 59, 0, 528, 530, 3, 78, 39, 0, 529, 520, 1, 0, 0, 0, 529, 521, 1, 0, 0, 0, 529, 522, 1, 0, 0, 0, 529, 523, 1, 0, 0, 0, 529, 524, 1, 0, 0, 0, 529, 525, 1, 0, 0, 0, 529, 526, 1, 0, 0, 0, 529, 527, 1, 0, 0, 0, 529, 528, 1, 0, 0, 0, 530, 113, 1, 0, 0, 0, 531, 532, 5, 31, 0, 0, 532, 115, 1, 0, 0, 0, 533, 534, 5, 17, 0, 0, 534, 535, 3, 142, 71, 0, 535, 536, 5, 74, 0, 0, 536, 539, 3, 18, 9, 0, 537, 538, 5, 79, 0, 0, 538, 540, 3, 60, 30, 0, 539, 537, 1, 0, 0, 0, 539, 540, 1, 0, 0, 0, 540, 117, 1, 0, 0, 0, 541, 545, 5, 7, 0, 0, 542, 543, 3, 46, 23, 0, 543, 544, 5, 58, 0, 0, 544, 546, 1, 0, 0, 0, 545, 542, 1, 0, 0, 0, 545, 546, 1, 0, 0, 0, 546, 547, 1, 0, 0, 0, 547, 548, 3, 132, 66, 0, 548, 549, 5, 79, 0, 0, 549, 550, 3, 60, 30, 0, 550, 119, 1, 0, 0, 0, 551, 552, 5, 18, 0, 0, 552, 553, 3, 148, 74, 0, 553, 121, 1, 0, 0, 0, 554, 555, 6, 61, -1, 0, 555, 556, 5, 71, 0, 0, 556, 584, 3, 122, 61, 8, 557, 584, 3, 128, 64, 0, 558, 584, 3, 124, 62, 0, 559, 561, 3, 128, 64, 0, 560, 562, 5, 71, 0, 0, 561, 560, 1, 0, 0, 0, 561, 562, 1, 0, 0, 0, 562, 563, 1, 0, 0, 0, 563, 564, 5, 67, 0, 0, 564, 565, 5, 99, 0, 0, 565, 570, 3, 128, 64, 0, 566, 567, 5, 62, 0, 0, 567, 569, 3, 128, 64, 0, 568, 566, 1, 0, 0, 0, 569, 572, 1, 0, 0, 0, 570, 568, 1, 0, 0, 0, 570, 571, 1, 0, 0, 0, 571, 573, 1, 0, 0, 0, 572, 570, 1, 0, 0, 0, 573, 574, 5, 100, 0, 0, 574, 584, 1, 0, 0, 0, 575, 576, 3, 128, 64, 0, 576, 578, 5, 68, 0, 0, 577, 579, 5, 71, 0, 0, 578, 577, 1, 0, 0, 0, 578, 579, 1, 0, 0, 0, 579, 580, 1, 0, 0, 0, 580, 581, 5, 72, 0, 0, 581, 584, 1, 0, 0, 0, 582, 584, 3, 126, 63, 0, 583, 554, 1, 0, 0, 0, 583, 557, 1, 0, 0, 0, 583, 558, 1, 0, 0, 0, 583, 559, 1, 0, 0, 0, 583, 575, 1, 0, 0, 0, 583, 582, 1, 0, 0, 0, 584, 593, 1, 0, 0, 0, 585, 586, 10, 5, 0, 0, 586, 587, 5, 56, 0, 0, 587, 592, 3, 122, 61, 6, 588, 589, 10, 4, 0, 0, 589, 590, 5, 75, 0, 0, 590, 592, 3, 122, 61, 5, 591, 585, 1, 0, 0, 0, 591, 588, 1, 0, 0, 0, 592, 595, 1, 0, 0, 0, 593, 591, 1, 0, 0, 0, 593, 594, 1, 0, 0, 0, 594, 123, 1, 0, 0, 0, 595, 593, 1, 0, 0, 0, 596, 598, 3, 128, 64, 0, 597, 599, 5, 71, 0, 0, 598, 597, 1, 0, 0, 0, 598, 599, 1, 0, 0, 0, 599, 600, 1, 0, 0, 0, 600, 601, 5, 70, 0, 0, 601, 602, 3, 152, 76, 0, 602, 611, 1, 0, 0, 0, 603, 605, 3, 128, 64, 0, 604, 606, 5, 71, 0, 0, 605, 604, 1, 0, 0, 0, 605, 606, 1, 0, 0, 0, 606, 607, 1, 0, 0, 0, 607, 608, 5, 77, 0, 0, 608, 609, 3, 152, 76, 0, 609, 611, 1, 0, 0, 0, 610, 596, 1, 0, 0, 0, 610, 603, 1, 0, 0, 0, 611, 125, 1, 0, 0, 0, 612, 615, 3, 46, 23, 0, 613, 614, 5, 60, 0, 0, 614, 616, 3, 10, 5, 0, 615, 613, 1, 0, 0, 0, 615, 616, 1, 0, 0, 0, 616, 617, 1, 0, 0, 0, 617, 618, 5, 61, 0, 0, 618, 619, 3, 142, 71, 0, 619, 127, 1, 0, 0, 0, 620, 626, 3, 130, 65, 0, 621, 622, 3, 130, 65, 0, 622, 623, 3, 154, 77, 0, 623, 624, 3, 130, 65, 0, 624, 626, 1, 0, 0, 0, 625, 620, 1, 0, 0, 0, 625, 621, 1, 0, 0, 0, 626, 129, 1, 0, 0, 0, 627, 628, 6, 65, -1, 0, 628, 632, 3, 132, 66, 0, 629, 630, 7, 4, 0, 0, 630, 632, 3, 130, 65, 3, 631, 627, 1, 0, 0, 0, 631, 629, 1, 0, 0, 0, 632, 641, 1, 0, 0, 0, 633, 634, 10, 2, 0, 0, 634, 635, 7, 5, 0, 0, 635, 640, 3, 130, 65, 3, 636, 637, 10, 1, 0, 0, 637, 638, 7, 4, 0, 0, 638, 640, 3, 130, 65, 2, 639, 633, 1, 0, 0, 0, 639, 636, 1, 0, 0, 0, 640, 643, 1, 0, 0, 0, 641, 639, 1, 0, 0, 0, 641, 642, 1, 0, 0, 0, 642, 131, 1, 0, 0, 0, 643, 641, 1, 0, 0, 0, 644, 645, 6, 66, -1, 0, 645, 653, 3, 142, 71, 0, 646, 653, 3, 46, 23, 0, 647, 653, 3, 134, 67, 0, 648, 649, 5, 99, 0, 0, 649, 650, 3, 122, 61, 0, 650, 651, 5, 100, 0, 0, 651, 653, 1, 0, 0, 0, 652, 644, 1, 0, 0, 0, 652, 646, 1, 0, 0, 0, 652, 647, 1, 0, 0, 0, 652, 648, 1, 0, 0, 0, 653, 659, 1, 0, 0, 0, 654, 655, 10, 1, 0, 0, 655, 656, 5, 60, 0, 0, 656, 658, 3, 10, 5, 0, 657, 654, 1, 0, 0, 0, 658, 661, 1, 0, 0, 0, 659, 657, 1, 0, 0, 0, 659, 660, 1, 0, 0, 0, 660, 133, 1, 0, 0, 0, 661, 659, 1, 0, 0, 0, 662, 663, 3, 136, 68, 0, 663, 677, 5, 99, 0, 0, 664, 678, 5, 89, 0, 0, 665, 670, 3, 122, 61, 0, 666, 667, 5, 62, 0, 0, 667, 669, 3, 122, 61, 0, 668, 666, 1, 0, 0, 0, 669, 672, 1, 0, 0, 0, 670, 668, 1, 0, 0, 0, 670, 671, 1, 0, 0, 0, 671, 675, 1, 0, 0, 0, 672, 670, 1, 0, 0, 0, 673, 674, 5, 62, 0, 0, 674, 676, 3, 138, 69, 0, 675, 673, 1, 0, 0, 0, 675, 676, 1, 0, 0, 0, 676, 678, 1, 0, 0, 0, 677, 664, 1, 0, 0, 0, 677, 665, 1, 0, 0, 0, 677, 678, 1, 0, 0, 0, 678, 679, 1, 0, 0, 0, 679, 680, 5, 100, 0, 0, 680, 135, 1, 0, 0, 0, 681, 682, 3, 60, 30, 0, 682, 137, 1, 0, 0, 0, 683, 684, 5, 92, 0, 0, 684, 689, 3, 140, 70, 0, 685, 686, 5, 62, 0, 0, 686, 688, 3, 140, 70, 0, 687, 685, 1, 0, 0, 0, 688, 691, 1, 0, 0, 0, 689, 687, 1, 0, 0, 0, 689, 690, 1, 0, 0, 0, 690, 692, 1, 0, 0, 0, 691, 689, 1, 0, 0, 0, 692, 693, 5, 93, 0, 0, 693, 139, 1, 0, 0, 0, 694, 695, 3, 152, 76, 0, 695, 696, 5, 61, 0, 0, 696, 697, 3, 142, 71, 0, 697, 141, 1, 0, 0, 0, 698, 741, 5, 72, 0, 0, 699, 700, 3, 150, 75, 0, 700, 701, 5, 101, 0, 0, 701, 741, 1, 0, 0, 0, 702, 741, 3, 148, 74, 0, 703, 741, 3, 150, 75, 0, 704, 741, 3, 144, 72, 0, 705, 741, 3, 56, 28, 0, 706, 741, 3, 152, 76, 0, 707, 708, 5, 97, 0, 0, 708, 713, 3, 146, 73, 0, 709, 710, 5, 62, 0, 0, 710, 712, 3, 146, 73, 0, 711, 709, 1, 0, 0, 0, 712, 715, 1, 0, 0, 0, 713, 711, 1, 0, 0, 0, 713, 714, 1, 0, 0, 0, 714, 716, 1, 0, 0, 0, 715, 713, 1, 0, 0, 0, 716, 717, 5, 98, 0, 0, 717, 741, 1, 0, 0, 0, 718, 719, 5, 97, 0, 0, 719, 724, 3, 144, 72, 0, 720, 721, 5, 62, 0, 0, 721, 723, 3, 144, 72, 0, 722, 720, 1, 0, 0, 0, 723, 726, 1, 0, 0, 0, 724, 722, 1, 0, 0, 0, 724, 725, 1, 0, 0, 0, 725, 727, 1, 0, 0, 0, 726, 724, 1, 0, 0, 0, 727, 728, 5, 98, 0, 0, 728, 741, 1, 0, 0, 0, 729, 730, 5, 97, 0, 0, 730, 735, 3, 152, 76, 0, 731, 732, 5, 62, 0, 0, 732, 734, 3, 152, 76, 0, 733, 731, 1, 0, 0, 0, 734, 737, 1, 0, 0, 0, 735, 733, 1, 0, 0, 0, 735, 736, 1, 0, 0, 0, 736, 738, 1, 0, 0, 0, 737, 735, 1, 0, 0, 0, 738, 739, 5, 98, 0, 0, 739, 741, 1, 0, 0, 0, 740, 698, 1, 0, 0, 0, 740, 699, 1, 0, 0, 0, 740, 702, 1, 0, 0, 0, 740, 703, 1, 0, 0, 0, 740, 704, 1, 0, 0, 0, 740, 705, 1, 0, 0, 0, 740, 706, 1, 0, 0, 0, 740, 707, 1, 0, 0, 0, 740, 718, 1, 0, 0, 0, 740, 729, 1, 0, 0, 0, 741, 143, 1, 0, 0, 0, 742, 743, 7, 6, 0, 0, 743, 145, 1, 0, 0, 0, 744, 747, 3, 148, 74, 0, 745, 747, 3, 150, 75, 0, 746, 744, 1, 0, 0, 0, 746, 745, 1, 0, 0, 0, 747, 147, 1, 0, 0, 0, 748, 750, 7, 4, 0, 0, 749, 748, 1, 0, 0, 0, 749, 750, 1, 0, 0, 0, 750, 751, 1, 0, 0, 0, 751, 752, 5, 55, 0, 0, 752, 149, 1, 0, 0, 0, 753, 755, 7, 4, 0, 0, 754, 753, 1, 0, 0, 0, 754, 755, 1, 0, 0, 0, 755, 756, 1, 0, 0, 0, 756, 757, 5, 54, 0, 0, 757, 151, 1, 0, 0, 0, 758, 759, 5, 53, 0, 0, 759, 153, 1, 0, 0, 0, 760, 761, 7, 7, 0, 0, 761, 155, 1, 0, 0, 0, 762, 763, 7, 8, 0, 0, 763, 764, 5, 114, 0, 0, 764, 765, 3, 158, 79, 0, 765, 766, 3, 160, 80, 0, 766, 157, 1, 0, 0, 0, 767, 768, 3, 28, 14, 0, 768, 159, 1, 0, 0, 0, 769, 770, 5, 74, 0, 0, 770, 775, 3, 162, 81, 0, 771, 772, 5, 62, 0, 0, 772, 774, 3, 162, 81, 0, 773, 771, 1, 0, 0, 0, 774, 777, 1, 0, 0, 0, 775, 773, 1, 0, 0, 0, 775, 776, 1, 0, 0, 0, 776, 161, 1, 0, 0, 0, 777, 775, 1, 0, 0, 0, 778, 779, 3, 128, 64, 0, 779, 163, 1, 0, 0, 0, 71, 175, 184, 215, 230, 236, 245, 251, 264, 268, 273, 279, 281, 295, 303, 307, 314, 320, 327, 335, 343, 351, 355, 359, 364, 375, 380, 384, 398, 409, 415, 429, 450, 458, 461, 466, 479, 485, 492, 503, 517, 529, 539, 545, 561, 570, 578, 583, 591, 593, 598, 605, 610, 615, 625, 631, 639, 641, 652, 659, 670, 675, 677, 689, 713, 724, 735, 740, 746, 749, 754, 775] \ No newline at end of file +[4, 1, 139, 781, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 2, 66, 7, 66, 2, 67, 7, 67, 2, 68, 7, 68, 2, 69, 7, 69, 2, 70, 7, 70, 2, 71, 7, 71, 2, 72, 7, 72, 2, 73, 7, 73, 2, 74, 7, 74, 2, 75, 7, 75, 2, 76, 7, 76, 2, 77, 7, 77, 2, 78, 7, 78, 2, 79, 7, 79, 2, 80, 7, 80, 2, 81, 7, 81, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 174, 8, 1, 10, 1, 12, 1, 177, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 185, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 216, 8, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 5, 7, 229, 8, 7, 10, 7, 12, 7, 232, 9, 7, 1, 8, 1, 8, 1, 8, 3, 8, 237, 8, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 5, 9, 244, 8, 9, 10, 9, 12, 9, 247, 9, 9, 1, 10, 1, 10, 1, 10, 3, 10, 252, 8, 10, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 5, 13, 263, 8, 13, 10, 13, 12, 13, 266, 9, 13, 1, 13, 3, 13, 269, 8, 13, 1, 14, 1, 14, 1, 14, 3, 14, 274, 8, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 280, 8, 14, 3, 14, 282, 8, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 5, 18, 294, 8, 18, 10, 18, 12, 18, 297, 9, 18, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 3, 20, 304, 8, 20, 1, 20, 1, 20, 3, 20, 308, 8, 20, 1, 21, 1, 21, 1, 21, 5, 21, 313, 8, 21, 10, 21, 12, 21, 316, 9, 21, 1, 22, 1, 22, 1, 22, 3, 22, 321, 8, 22, 1, 23, 1, 23, 1, 23, 5, 23, 326, 8, 23, 10, 23, 12, 23, 329, 9, 23, 1, 24, 1, 24, 1, 24, 5, 24, 334, 8, 24, 10, 24, 12, 24, 337, 9, 24, 1, 25, 1, 25, 1, 25, 5, 25, 342, 8, 25, 10, 25, 12, 25, 345, 9, 25, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 3, 27, 352, 8, 27, 1, 28, 1, 28, 3, 28, 356, 8, 28, 1, 29, 1, 29, 3, 29, 360, 8, 29, 1, 30, 1, 30, 1, 30, 3, 30, 365, 8, 30, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 5, 32, 374, 8, 32, 10, 32, 12, 32, 377, 9, 32, 1, 33, 1, 33, 3, 33, 381, 8, 33, 1, 33, 1, 33, 3, 33, 385, 8, 33, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 397, 8, 36, 10, 36, 12, 36, 400, 9, 36, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 3, 37, 410, 8, 37, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 416, 8, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 5, 41, 428, 8, 41, 10, 41, 12, 41, 431, 9, 41, 1, 42, 1, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 44, 1, 44, 1, 44, 1, 44, 1, 45, 1, 45, 1, 45, 1, 46, 1, 46, 1, 46, 1, 46, 3, 46, 451, 8, 46, 1, 46, 1, 46, 1, 46, 1, 46, 5, 46, 457, 8, 46, 10, 46, 12, 46, 460, 9, 46, 3, 46, 462, 8, 46, 1, 47, 1, 47, 1, 47, 3, 47, 467, 8, 47, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 1, 49, 1, 49, 3, 49, 480, 8, 49, 1, 50, 1, 50, 1, 50, 1, 50, 3, 50, 486, 8, 50, 1, 50, 1, 50, 1, 50, 1, 50, 1, 50, 3, 50, 493, 8, 50, 1, 51, 1, 51, 1, 51, 1, 52, 1, 52, 1, 52, 1, 53, 4, 53, 502, 8, 53, 11, 53, 12, 53, 503, 1, 54, 1, 54, 1, 54, 1, 54, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 5, 55, 516, 8, 55, 10, 55, 12, 55, 519, 9, 55, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 3, 56, 530, 8, 56, 1, 57, 1, 57, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 3, 58, 540, 8, 58, 1, 59, 1, 59, 1, 59, 1, 59, 3, 59, 546, 8, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 60, 1, 60, 1, 60, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 3, 61, 562, 8, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 5, 61, 569, 8, 61, 10, 61, 12, 61, 572, 9, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 3, 61, 579, 8, 61, 1, 61, 1, 61, 1, 61, 3, 61, 584, 8, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 5, 61, 592, 8, 61, 10, 61, 12, 61, 595, 9, 61, 1, 62, 1, 62, 3, 62, 599, 8, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 3, 62, 606, 8, 62, 1, 62, 1, 62, 1, 62, 3, 62, 611, 8, 62, 1, 63, 1, 63, 1, 63, 3, 63, 616, 8, 63, 1, 63, 1, 63, 1, 63, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 3, 64, 626, 8, 64, 1, 65, 1, 65, 1, 65, 1, 65, 3, 65, 632, 8, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 5, 65, 640, 8, 65, 10, 65, 12, 65, 643, 9, 65, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 3, 66, 653, 8, 66, 1, 66, 1, 66, 1, 66, 5, 66, 658, 8, 66, 10, 66, 12, 66, 661, 9, 66, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 5, 67, 669, 8, 67, 10, 67, 12, 67, 672, 9, 67, 1, 67, 1, 67, 3, 67, 676, 8, 67, 3, 67, 678, 8, 67, 1, 67, 1, 67, 1, 68, 1, 68, 1, 69, 1, 69, 1, 69, 1, 69, 5, 69, 688, 8, 69, 10, 69, 12, 69, 691, 9, 69, 1, 69, 1, 69, 1, 70, 1, 70, 1, 70, 1, 70, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 5, 71, 712, 8, 71, 10, 71, 12, 71, 715, 9, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 5, 71, 723, 8, 71, 10, 71, 12, 71, 726, 9, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 5, 71, 734, 8, 71, 10, 71, 12, 71, 737, 9, 71, 1, 71, 1, 71, 3, 71, 741, 8, 71, 1, 72, 1, 72, 1, 73, 1, 73, 3, 73, 747, 8, 73, 1, 74, 3, 74, 750, 8, 74, 1, 74, 1, 74, 1, 75, 3, 75, 755, 8, 75, 1, 75, 1, 75, 1, 76, 1, 76, 1, 77, 1, 77, 1, 78, 1, 78, 1, 78, 1, 78, 1, 78, 1, 79, 1, 79, 1, 80, 1, 80, 1, 80, 1, 80, 5, 80, 774, 8, 80, 10, 80, 12, 80, 777, 9, 80, 1, 81, 1, 81, 1, 81, 0, 5, 2, 110, 122, 130, 132, 82, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 0, 9, 2, 0, 53, 53, 107, 107, 1, 0, 101, 102, 2, 0, 57, 57, 63, 63, 2, 0, 66, 66, 69, 69, 1, 0, 87, 88, 1, 0, 89, 91, 2, 0, 65, 65, 78, 78, 2, 0, 80, 80, 82, 86, 2, 0, 22, 22, 24, 25, 816, 0, 164, 1, 0, 0, 0, 2, 167, 1, 0, 0, 0, 4, 184, 1, 0, 0, 0, 6, 215, 1, 0, 0, 0, 8, 217, 1, 0, 0, 0, 10, 220, 1, 0, 0, 0, 12, 222, 1, 0, 0, 0, 14, 225, 1, 0, 0, 0, 16, 236, 1, 0, 0, 0, 18, 240, 1, 0, 0, 0, 20, 248, 1, 0, 0, 0, 22, 253, 1, 0, 0, 0, 24, 256, 1, 0, 0, 0, 26, 259, 1, 0, 0, 0, 28, 281, 1, 0, 0, 0, 30, 283, 1, 0, 0, 0, 32, 285, 1, 0, 0, 0, 34, 287, 1, 0, 0, 0, 36, 289, 1, 0, 0, 0, 38, 298, 1, 0, 0, 0, 40, 301, 1, 0, 0, 0, 42, 309, 1, 0, 0, 0, 44, 317, 1, 0, 0, 0, 46, 322, 1, 0, 0, 0, 48, 330, 1, 0, 0, 0, 50, 338, 1, 0, 0, 0, 52, 346, 1, 0, 0, 0, 54, 351, 1, 0, 0, 0, 56, 355, 1, 0, 0, 0, 58, 359, 1, 0, 0, 0, 60, 364, 1, 0, 0, 0, 62, 366, 1, 0, 0, 0, 64, 369, 1, 0, 0, 0, 66, 378, 1, 0, 0, 0, 68, 386, 1, 0, 0, 0, 70, 389, 1, 0, 0, 0, 72, 392, 1, 0, 0, 0, 74, 409, 1, 0, 0, 0, 76, 411, 1, 0, 0, 0, 78, 417, 1, 0, 0, 0, 80, 421, 1, 0, 0, 0, 82, 424, 1, 0, 0, 0, 84, 432, 1, 0, 0, 0, 86, 436, 1, 0, 0, 0, 88, 439, 1, 0, 0, 0, 90, 443, 1, 0, 0, 0, 92, 446, 1, 0, 0, 0, 94, 466, 1, 0, 0, 0, 96, 470, 1, 0, 0, 0, 98, 475, 1, 0, 0, 0, 100, 481, 1, 0, 0, 0, 102, 494, 1, 0, 0, 0, 104, 497, 1, 0, 0, 0, 106, 501, 1, 0, 0, 0, 108, 505, 1, 0, 0, 0, 110, 509, 1, 0, 0, 0, 112, 529, 1, 0, 0, 0, 114, 531, 1, 0, 0, 0, 116, 533, 1, 0, 0, 0, 118, 541, 1, 0, 0, 0, 120, 551, 1, 0, 0, 0, 122, 583, 1, 0, 0, 0, 124, 610, 1, 0, 0, 0, 126, 612, 1, 0, 0, 0, 128, 625, 1, 0, 0, 0, 130, 631, 1, 0, 0, 0, 132, 652, 1, 0, 0, 0, 134, 662, 1, 0, 0, 0, 136, 681, 1, 0, 0, 0, 138, 683, 1, 0, 0, 0, 140, 694, 1, 0, 0, 0, 142, 740, 1, 0, 0, 0, 144, 742, 1, 0, 0, 0, 146, 746, 1, 0, 0, 0, 148, 749, 1, 0, 0, 0, 150, 754, 1, 0, 0, 0, 152, 758, 1, 0, 0, 0, 154, 760, 1, 0, 0, 0, 156, 762, 1, 0, 0, 0, 158, 767, 1, 0, 0, 0, 160, 769, 1, 0, 0, 0, 162, 778, 1, 0, 0, 0, 164, 165, 3, 2, 1, 0, 165, 166, 5, 0, 0, 1, 166, 1, 1, 0, 0, 0, 167, 168, 6, 1, -1, 0, 168, 169, 3, 4, 2, 0, 169, 175, 1, 0, 0, 0, 170, 171, 10, 1, 0, 0, 171, 172, 5, 52, 0, 0, 172, 174, 3, 6, 3, 0, 173, 170, 1, 0, 0, 0, 174, 177, 1, 0, 0, 0, 175, 173, 1, 0, 0, 0, 175, 176, 1, 0, 0, 0, 176, 3, 1, 0, 0, 0, 177, 175, 1, 0, 0, 0, 178, 185, 3, 86, 43, 0, 179, 185, 3, 22, 11, 0, 180, 185, 3, 12, 6, 0, 181, 185, 3, 90, 45, 0, 182, 183, 4, 2, 1, 0, 183, 185, 3, 24, 12, 0, 184, 178, 1, 0, 0, 0, 184, 179, 1, 0, 0, 0, 184, 180, 1, 0, 0, 0, 184, 181, 1, 0, 0, 0, 184, 182, 1, 0, 0, 0, 185, 5, 1, 0, 0, 0, 186, 216, 3, 38, 19, 0, 187, 216, 3, 8, 4, 0, 188, 216, 3, 68, 34, 0, 189, 216, 3, 62, 31, 0, 190, 216, 3, 40, 20, 0, 191, 216, 3, 64, 32, 0, 192, 216, 3, 70, 35, 0, 193, 216, 3, 72, 36, 0, 194, 216, 3, 76, 38, 0, 195, 216, 3, 78, 39, 0, 196, 216, 3, 92, 46, 0, 197, 216, 3, 80, 40, 0, 198, 216, 3, 156, 78, 0, 199, 216, 3, 100, 50, 0, 200, 216, 3, 118, 59, 0, 201, 202, 4, 3, 2, 0, 202, 216, 3, 98, 49, 0, 203, 204, 4, 3, 3, 0, 204, 216, 3, 96, 48, 0, 205, 206, 4, 3, 4, 0, 206, 216, 3, 102, 51, 0, 207, 208, 4, 3, 5, 0, 208, 216, 3, 104, 52, 0, 209, 210, 4, 3, 6, 0, 210, 216, 3, 116, 58, 0, 211, 212, 4, 3, 7, 0, 212, 216, 3, 114, 57, 0, 213, 214, 4, 3, 8, 0, 214, 216, 3, 120, 60, 0, 215, 186, 1, 0, 0, 0, 215, 187, 1, 0, 0, 0, 215, 188, 1, 0, 0, 0, 215, 189, 1, 0, 0, 0, 215, 190, 1, 0, 0, 0, 215, 191, 1, 0, 0, 0, 215, 192, 1, 0, 0, 0, 215, 193, 1, 0, 0, 0, 215, 194, 1, 0, 0, 0, 215, 195, 1, 0, 0, 0, 215, 196, 1, 0, 0, 0, 215, 197, 1, 0, 0, 0, 215, 198, 1, 0, 0, 0, 215, 199, 1, 0, 0, 0, 215, 200, 1, 0, 0, 0, 215, 201, 1, 0, 0, 0, 215, 203, 1, 0, 0, 0, 215, 205, 1, 0, 0, 0, 215, 207, 1, 0, 0, 0, 215, 209, 1, 0, 0, 0, 215, 211, 1, 0, 0, 0, 215, 213, 1, 0, 0, 0, 216, 7, 1, 0, 0, 0, 217, 218, 5, 15, 0, 0, 218, 219, 3, 122, 61, 0, 219, 9, 1, 0, 0, 0, 220, 221, 3, 52, 26, 0, 221, 11, 1, 0, 0, 0, 222, 223, 5, 12, 0, 0, 223, 224, 3, 14, 7, 0, 224, 13, 1, 0, 0, 0, 225, 230, 3, 16, 8, 0, 226, 227, 5, 62, 0, 0, 227, 229, 3, 16, 8, 0, 228, 226, 1, 0, 0, 0, 229, 232, 1, 0, 0, 0, 230, 228, 1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 15, 1, 0, 0, 0, 232, 230, 1, 0, 0, 0, 233, 234, 3, 46, 23, 0, 234, 235, 5, 58, 0, 0, 235, 237, 1, 0, 0, 0, 236, 233, 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 238, 1, 0, 0, 0, 238, 239, 3, 122, 61, 0, 239, 17, 1, 0, 0, 0, 240, 245, 3, 20, 10, 0, 241, 242, 5, 62, 0, 0, 242, 244, 3, 20, 10, 0, 243, 241, 1, 0, 0, 0, 244, 247, 1, 0, 0, 0, 245, 243, 1, 0, 0, 0, 245, 246, 1, 0, 0, 0, 246, 19, 1, 0, 0, 0, 247, 245, 1, 0, 0, 0, 248, 251, 3, 46, 23, 0, 249, 250, 5, 58, 0, 0, 250, 252, 3, 122, 61, 0, 251, 249, 1, 0, 0, 0, 251, 252, 1, 0, 0, 0, 252, 21, 1, 0, 0, 0, 253, 254, 5, 19, 0, 0, 254, 255, 3, 26, 13, 0, 255, 23, 1, 0, 0, 0, 256, 257, 5, 20, 0, 0, 257, 258, 3, 26, 13, 0, 258, 25, 1, 0, 0, 0, 259, 264, 3, 28, 14, 0, 260, 261, 5, 62, 0, 0, 261, 263, 3, 28, 14, 0, 262, 260, 1, 0, 0, 0, 263, 266, 1, 0, 0, 0, 264, 262, 1, 0, 0, 0, 264, 265, 1, 0, 0, 0, 265, 268, 1, 0, 0, 0, 266, 264, 1, 0, 0, 0, 267, 269, 3, 36, 18, 0, 268, 267, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, 27, 1, 0, 0, 0, 270, 271, 3, 30, 15, 0, 271, 272, 5, 61, 0, 0, 272, 274, 1, 0, 0, 0, 273, 270, 1, 0, 0, 0, 273, 274, 1, 0, 0, 0, 274, 275, 1, 0, 0, 0, 275, 282, 3, 34, 17, 0, 276, 279, 3, 34, 17, 0, 277, 278, 5, 60, 0, 0, 278, 280, 3, 32, 16, 0, 279, 277, 1, 0, 0, 0, 279, 280, 1, 0, 0, 0, 280, 282, 1, 0, 0, 0, 281, 273, 1, 0, 0, 0, 281, 276, 1, 0, 0, 0, 282, 29, 1, 0, 0, 0, 283, 284, 7, 0, 0, 0, 284, 31, 1, 0, 0, 0, 285, 286, 7, 0, 0, 0, 286, 33, 1, 0, 0, 0, 287, 288, 7, 0, 0, 0, 288, 35, 1, 0, 0, 0, 289, 290, 5, 106, 0, 0, 290, 295, 5, 107, 0, 0, 291, 292, 5, 62, 0, 0, 292, 294, 5, 107, 0, 0, 293, 291, 1, 0, 0, 0, 294, 297, 1, 0, 0, 0, 295, 293, 1, 0, 0, 0, 295, 296, 1, 0, 0, 0, 296, 37, 1, 0, 0, 0, 297, 295, 1, 0, 0, 0, 298, 299, 5, 9, 0, 0, 299, 300, 3, 14, 7, 0, 300, 39, 1, 0, 0, 0, 301, 303, 5, 14, 0, 0, 302, 304, 3, 42, 21, 0, 303, 302, 1, 0, 0, 0, 303, 304, 1, 0, 0, 0, 304, 307, 1, 0, 0, 0, 305, 306, 5, 59, 0, 0, 306, 308, 3, 14, 7, 0, 307, 305, 1, 0, 0, 0, 307, 308, 1, 0, 0, 0, 308, 41, 1, 0, 0, 0, 309, 314, 3, 44, 22, 0, 310, 311, 5, 62, 0, 0, 311, 313, 3, 44, 22, 0, 312, 310, 1, 0, 0, 0, 313, 316, 1, 0, 0, 0, 314, 312, 1, 0, 0, 0, 314, 315, 1, 0, 0, 0, 315, 43, 1, 0, 0, 0, 316, 314, 1, 0, 0, 0, 317, 320, 3, 16, 8, 0, 318, 319, 5, 15, 0, 0, 319, 321, 3, 122, 61, 0, 320, 318, 1, 0, 0, 0, 320, 321, 1, 0, 0, 0, 321, 45, 1, 0, 0, 0, 322, 327, 3, 60, 30, 0, 323, 324, 5, 64, 0, 0, 324, 326, 3, 60, 30, 0, 325, 323, 1, 0, 0, 0, 326, 329, 1, 0, 0, 0, 327, 325, 1, 0, 0, 0, 327, 328, 1, 0, 0, 0, 328, 47, 1, 0, 0, 0, 329, 327, 1, 0, 0, 0, 330, 335, 3, 54, 27, 0, 331, 332, 5, 64, 0, 0, 332, 334, 3, 54, 27, 0, 333, 331, 1, 0, 0, 0, 334, 337, 1, 0, 0, 0, 335, 333, 1, 0, 0, 0, 335, 336, 1, 0, 0, 0, 336, 49, 1, 0, 0, 0, 337, 335, 1, 0, 0, 0, 338, 343, 3, 48, 24, 0, 339, 340, 5, 62, 0, 0, 340, 342, 3, 48, 24, 0, 341, 339, 1, 0, 0, 0, 342, 345, 1, 0, 0, 0, 343, 341, 1, 0, 0, 0, 343, 344, 1, 0, 0, 0, 344, 51, 1, 0, 0, 0, 345, 343, 1, 0, 0, 0, 346, 347, 7, 1, 0, 0, 347, 53, 1, 0, 0, 0, 348, 352, 5, 128, 0, 0, 349, 352, 3, 56, 28, 0, 350, 352, 3, 58, 29, 0, 351, 348, 1, 0, 0, 0, 351, 349, 1, 0, 0, 0, 351, 350, 1, 0, 0, 0, 352, 55, 1, 0, 0, 0, 353, 356, 5, 76, 0, 0, 354, 356, 5, 95, 0, 0, 355, 353, 1, 0, 0, 0, 355, 354, 1, 0, 0, 0, 356, 57, 1, 0, 0, 0, 357, 360, 5, 94, 0, 0, 358, 360, 5, 96, 0, 0, 359, 357, 1, 0, 0, 0, 359, 358, 1, 0, 0, 0, 360, 59, 1, 0, 0, 0, 361, 365, 3, 52, 26, 0, 362, 365, 3, 56, 28, 0, 363, 365, 3, 58, 29, 0, 364, 361, 1, 0, 0, 0, 364, 362, 1, 0, 0, 0, 364, 363, 1, 0, 0, 0, 365, 61, 1, 0, 0, 0, 366, 367, 5, 11, 0, 0, 367, 368, 3, 142, 71, 0, 368, 63, 1, 0, 0, 0, 369, 370, 5, 13, 0, 0, 370, 375, 3, 66, 33, 0, 371, 372, 5, 62, 0, 0, 372, 374, 3, 66, 33, 0, 373, 371, 1, 0, 0, 0, 374, 377, 1, 0, 0, 0, 375, 373, 1, 0, 0, 0, 375, 376, 1, 0, 0, 0, 376, 65, 1, 0, 0, 0, 377, 375, 1, 0, 0, 0, 378, 380, 3, 122, 61, 0, 379, 381, 7, 2, 0, 0, 380, 379, 1, 0, 0, 0, 380, 381, 1, 0, 0, 0, 381, 384, 1, 0, 0, 0, 382, 383, 5, 73, 0, 0, 383, 385, 7, 3, 0, 0, 384, 382, 1, 0, 0, 0, 384, 385, 1, 0, 0, 0, 385, 67, 1, 0, 0, 0, 386, 387, 5, 29, 0, 0, 387, 388, 3, 50, 25, 0, 388, 69, 1, 0, 0, 0, 389, 390, 5, 28, 0, 0, 390, 391, 3, 50, 25, 0, 391, 71, 1, 0, 0, 0, 392, 393, 5, 32, 0, 0, 393, 398, 3, 74, 37, 0, 394, 395, 5, 62, 0, 0, 395, 397, 3, 74, 37, 0, 396, 394, 1, 0, 0, 0, 397, 400, 1, 0, 0, 0, 398, 396, 1, 0, 0, 0, 398, 399, 1, 0, 0, 0, 399, 73, 1, 0, 0, 0, 400, 398, 1, 0, 0, 0, 401, 402, 3, 48, 24, 0, 402, 403, 5, 132, 0, 0, 403, 404, 3, 48, 24, 0, 404, 410, 1, 0, 0, 0, 405, 406, 3, 48, 24, 0, 406, 407, 5, 58, 0, 0, 407, 408, 3, 48, 24, 0, 408, 410, 1, 0, 0, 0, 409, 401, 1, 0, 0, 0, 409, 405, 1, 0, 0, 0, 410, 75, 1, 0, 0, 0, 411, 412, 5, 8, 0, 0, 412, 413, 3, 132, 66, 0, 413, 415, 3, 152, 76, 0, 414, 416, 3, 82, 41, 0, 415, 414, 1, 0, 0, 0, 415, 416, 1, 0, 0, 0, 416, 77, 1, 0, 0, 0, 417, 418, 5, 10, 0, 0, 418, 419, 3, 132, 66, 0, 419, 420, 3, 152, 76, 0, 420, 79, 1, 0, 0, 0, 421, 422, 5, 27, 0, 0, 422, 423, 3, 46, 23, 0, 423, 81, 1, 0, 0, 0, 424, 429, 3, 84, 42, 0, 425, 426, 5, 62, 0, 0, 426, 428, 3, 84, 42, 0, 427, 425, 1, 0, 0, 0, 428, 431, 1, 0, 0, 0, 429, 427, 1, 0, 0, 0, 429, 430, 1, 0, 0, 0, 430, 83, 1, 0, 0, 0, 431, 429, 1, 0, 0, 0, 432, 433, 3, 52, 26, 0, 433, 434, 5, 58, 0, 0, 434, 435, 3, 132, 66, 0, 435, 85, 1, 0, 0, 0, 436, 437, 5, 6, 0, 0, 437, 438, 3, 88, 44, 0, 438, 87, 1, 0, 0, 0, 439, 440, 5, 97, 0, 0, 440, 441, 3, 2, 1, 0, 441, 442, 5, 98, 0, 0, 442, 89, 1, 0, 0, 0, 443, 444, 5, 33, 0, 0, 444, 445, 5, 136, 0, 0, 445, 91, 1, 0, 0, 0, 446, 447, 5, 5, 0, 0, 447, 450, 5, 38, 0, 0, 448, 449, 5, 74, 0, 0, 449, 451, 3, 48, 24, 0, 450, 448, 1, 0, 0, 0, 450, 451, 1, 0, 0, 0, 451, 461, 1, 0, 0, 0, 452, 453, 5, 79, 0, 0, 453, 458, 3, 94, 47, 0, 454, 455, 5, 62, 0, 0, 455, 457, 3, 94, 47, 0, 456, 454, 1, 0, 0, 0, 457, 460, 1, 0, 0, 0, 458, 456, 1, 0, 0, 0, 458, 459, 1, 0, 0, 0, 459, 462, 1, 0, 0, 0, 460, 458, 1, 0, 0, 0, 461, 452, 1, 0, 0, 0, 461, 462, 1, 0, 0, 0, 462, 93, 1, 0, 0, 0, 463, 464, 3, 48, 24, 0, 464, 465, 5, 58, 0, 0, 465, 467, 1, 0, 0, 0, 466, 463, 1, 0, 0, 0, 466, 467, 1, 0, 0, 0, 467, 468, 1, 0, 0, 0, 468, 469, 3, 48, 24, 0, 469, 95, 1, 0, 0, 0, 470, 471, 5, 26, 0, 0, 471, 472, 3, 28, 14, 0, 472, 473, 5, 74, 0, 0, 473, 474, 3, 50, 25, 0, 474, 97, 1, 0, 0, 0, 475, 476, 5, 16, 0, 0, 476, 479, 3, 42, 21, 0, 477, 478, 5, 59, 0, 0, 478, 480, 3, 14, 7, 0, 479, 477, 1, 0, 0, 0, 479, 480, 1, 0, 0, 0, 480, 99, 1, 0, 0, 0, 481, 482, 5, 4, 0, 0, 482, 485, 3, 46, 23, 0, 483, 484, 5, 74, 0, 0, 484, 486, 3, 46, 23, 0, 485, 483, 1, 0, 0, 0, 485, 486, 1, 0, 0, 0, 486, 492, 1, 0, 0, 0, 487, 488, 5, 132, 0, 0, 488, 489, 3, 46, 23, 0, 489, 490, 5, 62, 0, 0, 490, 491, 3, 46, 23, 0, 491, 493, 1, 0, 0, 0, 492, 487, 1, 0, 0, 0, 492, 493, 1, 0, 0, 0, 493, 101, 1, 0, 0, 0, 494, 495, 5, 30, 0, 0, 495, 496, 3, 50, 25, 0, 496, 103, 1, 0, 0, 0, 497, 498, 5, 21, 0, 0, 498, 499, 3, 106, 53, 0, 499, 105, 1, 0, 0, 0, 500, 502, 3, 108, 54, 0, 501, 500, 1, 0, 0, 0, 502, 503, 1, 0, 0, 0, 503, 501, 1, 0, 0, 0, 503, 504, 1, 0, 0, 0, 504, 107, 1, 0, 0, 0, 505, 506, 5, 99, 0, 0, 506, 507, 3, 110, 55, 0, 507, 508, 5, 100, 0, 0, 508, 109, 1, 0, 0, 0, 509, 510, 6, 55, -1, 0, 510, 511, 3, 112, 56, 0, 511, 517, 1, 0, 0, 0, 512, 513, 10, 1, 0, 0, 513, 514, 5, 52, 0, 0, 514, 516, 3, 112, 56, 0, 515, 512, 1, 0, 0, 0, 516, 519, 1, 0, 0, 0, 517, 515, 1, 0, 0, 0, 517, 518, 1, 0, 0, 0, 518, 111, 1, 0, 0, 0, 519, 517, 1, 0, 0, 0, 520, 530, 3, 38, 19, 0, 521, 530, 3, 8, 4, 0, 522, 530, 3, 62, 31, 0, 523, 530, 3, 40, 20, 0, 524, 530, 3, 64, 32, 0, 525, 530, 3, 76, 38, 0, 526, 530, 3, 100, 50, 0, 527, 530, 3, 118, 59, 0, 528, 530, 3, 78, 39, 0, 529, 520, 1, 0, 0, 0, 529, 521, 1, 0, 0, 0, 529, 522, 1, 0, 0, 0, 529, 523, 1, 0, 0, 0, 529, 524, 1, 0, 0, 0, 529, 525, 1, 0, 0, 0, 529, 526, 1, 0, 0, 0, 529, 527, 1, 0, 0, 0, 529, 528, 1, 0, 0, 0, 530, 113, 1, 0, 0, 0, 531, 532, 5, 31, 0, 0, 532, 115, 1, 0, 0, 0, 533, 534, 5, 17, 0, 0, 534, 535, 3, 142, 71, 0, 535, 536, 5, 74, 0, 0, 536, 539, 3, 18, 9, 0, 537, 538, 5, 79, 0, 0, 538, 540, 3, 60, 30, 0, 539, 537, 1, 0, 0, 0, 539, 540, 1, 0, 0, 0, 540, 117, 1, 0, 0, 0, 541, 545, 5, 7, 0, 0, 542, 543, 3, 46, 23, 0, 543, 544, 5, 58, 0, 0, 544, 546, 1, 0, 0, 0, 545, 542, 1, 0, 0, 0, 545, 546, 1, 0, 0, 0, 546, 547, 1, 0, 0, 0, 547, 548, 3, 132, 66, 0, 548, 549, 5, 79, 0, 0, 549, 550, 3, 60, 30, 0, 550, 119, 1, 0, 0, 0, 551, 552, 5, 18, 0, 0, 552, 553, 3, 148, 74, 0, 553, 121, 1, 0, 0, 0, 554, 555, 6, 61, -1, 0, 555, 556, 5, 71, 0, 0, 556, 584, 3, 122, 61, 8, 557, 584, 3, 128, 64, 0, 558, 584, 3, 124, 62, 0, 559, 561, 3, 128, 64, 0, 560, 562, 5, 71, 0, 0, 561, 560, 1, 0, 0, 0, 561, 562, 1, 0, 0, 0, 562, 563, 1, 0, 0, 0, 563, 564, 5, 67, 0, 0, 564, 565, 5, 99, 0, 0, 565, 570, 3, 128, 64, 0, 566, 567, 5, 62, 0, 0, 567, 569, 3, 128, 64, 0, 568, 566, 1, 0, 0, 0, 569, 572, 1, 0, 0, 0, 570, 568, 1, 0, 0, 0, 570, 571, 1, 0, 0, 0, 571, 573, 1, 0, 0, 0, 572, 570, 1, 0, 0, 0, 573, 574, 5, 100, 0, 0, 574, 584, 1, 0, 0, 0, 575, 576, 3, 128, 64, 0, 576, 578, 5, 68, 0, 0, 577, 579, 5, 71, 0, 0, 578, 577, 1, 0, 0, 0, 578, 579, 1, 0, 0, 0, 579, 580, 1, 0, 0, 0, 580, 581, 5, 72, 0, 0, 581, 584, 1, 0, 0, 0, 582, 584, 3, 126, 63, 0, 583, 554, 1, 0, 0, 0, 583, 557, 1, 0, 0, 0, 583, 558, 1, 0, 0, 0, 583, 559, 1, 0, 0, 0, 583, 575, 1, 0, 0, 0, 583, 582, 1, 0, 0, 0, 584, 593, 1, 0, 0, 0, 585, 586, 10, 5, 0, 0, 586, 587, 5, 56, 0, 0, 587, 592, 3, 122, 61, 6, 588, 589, 10, 4, 0, 0, 589, 590, 5, 75, 0, 0, 590, 592, 3, 122, 61, 5, 591, 585, 1, 0, 0, 0, 591, 588, 1, 0, 0, 0, 592, 595, 1, 0, 0, 0, 593, 591, 1, 0, 0, 0, 593, 594, 1, 0, 0, 0, 594, 123, 1, 0, 0, 0, 595, 593, 1, 0, 0, 0, 596, 598, 3, 128, 64, 0, 597, 599, 5, 71, 0, 0, 598, 597, 1, 0, 0, 0, 598, 599, 1, 0, 0, 0, 599, 600, 1, 0, 0, 0, 600, 601, 5, 70, 0, 0, 601, 602, 3, 152, 76, 0, 602, 611, 1, 0, 0, 0, 603, 605, 3, 128, 64, 0, 604, 606, 5, 71, 0, 0, 605, 604, 1, 0, 0, 0, 605, 606, 1, 0, 0, 0, 606, 607, 1, 0, 0, 0, 607, 608, 5, 77, 0, 0, 608, 609, 3, 152, 76, 0, 609, 611, 1, 0, 0, 0, 610, 596, 1, 0, 0, 0, 610, 603, 1, 0, 0, 0, 611, 125, 1, 0, 0, 0, 612, 615, 3, 46, 23, 0, 613, 614, 5, 60, 0, 0, 614, 616, 3, 10, 5, 0, 615, 613, 1, 0, 0, 0, 615, 616, 1, 0, 0, 0, 616, 617, 1, 0, 0, 0, 617, 618, 5, 61, 0, 0, 618, 619, 3, 142, 71, 0, 619, 127, 1, 0, 0, 0, 620, 626, 3, 130, 65, 0, 621, 622, 3, 130, 65, 0, 622, 623, 3, 154, 77, 0, 623, 624, 3, 130, 65, 0, 624, 626, 1, 0, 0, 0, 625, 620, 1, 0, 0, 0, 625, 621, 1, 0, 0, 0, 626, 129, 1, 0, 0, 0, 627, 628, 6, 65, -1, 0, 628, 632, 3, 132, 66, 0, 629, 630, 7, 4, 0, 0, 630, 632, 3, 130, 65, 3, 631, 627, 1, 0, 0, 0, 631, 629, 1, 0, 0, 0, 632, 641, 1, 0, 0, 0, 633, 634, 10, 2, 0, 0, 634, 635, 7, 5, 0, 0, 635, 640, 3, 130, 65, 3, 636, 637, 10, 1, 0, 0, 637, 638, 7, 4, 0, 0, 638, 640, 3, 130, 65, 2, 639, 633, 1, 0, 0, 0, 639, 636, 1, 0, 0, 0, 640, 643, 1, 0, 0, 0, 641, 639, 1, 0, 0, 0, 641, 642, 1, 0, 0, 0, 642, 131, 1, 0, 0, 0, 643, 641, 1, 0, 0, 0, 644, 645, 6, 66, -1, 0, 645, 653, 3, 142, 71, 0, 646, 653, 3, 46, 23, 0, 647, 653, 3, 134, 67, 0, 648, 649, 5, 99, 0, 0, 649, 650, 3, 122, 61, 0, 650, 651, 5, 100, 0, 0, 651, 653, 1, 0, 0, 0, 652, 644, 1, 0, 0, 0, 652, 646, 1, 0, 0, 0, 652, 647, 1, 0, 0, 0, 652, 648, 1, 0, 0, 0, 653, 659, 1, 0, 0, 0, 654, 655, 10, 1, 0, 0, 655, 656, 5, 60, 0, 0, 656, 658, 3, 10, 5, 0, 657, 654, 1, 0, 0, 0, 658, 661, 1, 0, 0, 0, 659, 657, 1, 0, 0, 0, 659, 660, 1, 0, 0, 0, 660, 133, 1, 0, 0, 0, 661, 659, 1, 0, 0, 0, 662, 663, 3, 136, 68, 0, 663, 677, 5, 99, 0, 0, 664, 678, 5, 89, 0, 0, 665, 670, 3, 122, 61, 0, 666, 667, 5, 62, 0, 0, 667, 669, 3, 122, 61, 0, 668, 666, 1, 0, 0, 0, 669, 672, 1, 0, 0, 0, 670, 668, 1, 0, 0, 0, 670, 671, 1, 0, 0, 0, 671, 675, 1, 0, 0, 0, 672, 670, 1, 0, 0, 0, 673, 674, 5, 62, 0, 0, 674, 676, 3, 138, 69, 0, 675, 673, 1, 0, 0, 0, 675, 676, 1, 0, 0, 0, 676, 678, 1, 0, 0, 0, 677, 664, 1, 0, 0, 0, 677, 665, 1, 0, 0, 0, 677, 678, 1, 0, 0, 0, 678, 679, 1, 0, 0, 0, 679, 680, 5, 100, 0, 0, 680, 135, 1, 0, 0, 0, 681, 682, 3, 60, 30, 0, 682, 137, 1, 0, 0, 0, 683, 684, 5, 92, 0, 0, 684, 689, 3, 140, 70, 0, 685, 686, 5, 62, 0, 0, 686, 688, 3, 140, 70, 0, 687, 685, 1, 0, 0, 0, 688, 691, 1, 0, 0, 0, 689, 687, 1, 0, 0, 0, 689, 690, 1, 0, 0, 0, 690, 692, 1, 0, 0, 0, 691, 689, 1, 0, 0, 0, 692, 693, 5, 93, 0, 0, 693, 139, 1, 0, 0, 0, 694, 695, 3, 152, 76, 0, 695, 696, 5, 61, 0, 0, 696, 697, 3, 142, 71, 0, 697, 141, 1, 0, 0, 0, 698, 741, 5, 72, 0, 0, 699, 700, 3, 150, 75, 0, 700, 701, 5, 101, 0, 0, 701, 741, 1, 0, 0, 0, 702, 741, 3, 148, 74, 0, 703, 741, 3, 150, 75, 0, 704, 741, 3, 144, 72, 0, 705, 741, 3, 56, 28, 0, 706, 741, 3, 152, 76, 0, 707, 708, 5, 97, 0, 0, 708, 713, 3, 146, 73, 0, 709, 710, 5, 62, 0, 0, 710, 712, 3, 146, 73, 0, 711, 709, 1, 0, 0, 0, 712, 715, 1, 0, 0, 0, 713, 711, 1, 0, 0, 0, 713, 714, 1, 0, 0, 0, 714, 716, 1, 0, 0, 0, 715, 713, 1, 0, 0, 0, 716, 717, 5, 98, 0, 0, 717, 741, 1, 0, 0, 0, 718, 719, 5, 97, 0, 0, 719, 724, 3, 144, 72, 0, 720, 721, 5, 62, 0, 0, 721, 723, 3, 144, 72, 0, 722, 720, 1, 0, 0, 0, 723, 726, 1, 0, 0, 0, 724, 722, 1, 0, 0, 0, 724, 725, 1, 0, 0, 0, 725, 727, 1, 0, 0, 0, 726, 724, 1, 0, 0, 0, 727, 728, 5, 98, 0, 0, 728, 741, 1, 0, 0, 0, 729, 730, 5, 97, 0, 0, 730, 735, 3, 152, 76, 0, 731, 732, 5, 62, 0, 0, 732, 734, 3, 152, 76, 0, 733, 731, 1, 0, 0, 0, 734, 737, 1, 0, 0, 0, 735, 733, 1, 0, 0, 0, 735, 736, 1, 0, 0, 0, 736, 738, 1, 0, 0, 0, 737, 735, 1, 0, 0, 0, 738, 739, 5, 98, 0, 0, 739, 741, 1, 0, 0, 0, 740, 698, 1, 0, 0, 0, 740, 699, 1, 0, 0, 0, 740, 702, 1, 0, 0, 0, 740, 703, 1, 0, 0, 0, 740, 704, 1, 0, 0, 0, 740, 705, 1, 0, 0, 0, 740, 706, 1, 0, 0, 0, 740, 707, 1, 0, 0, 0, 740, 718, 1, 0, 0, 0, 740, 729, 1, 0, 0, 0, 741, 143, 1, 0, 0, 0, 742, 743, 7, 6, 0, 0, 743, 145, 1, 0, 0, 0, 744, 747, 3, 148, 74, 0, 745, 747, 3, 150, 75, 0, 746, 744, 1, 0, 0, 0, 746, 745, 1, 0, 0, 0, 747, 147, 1, 0, 0, 0, 748, 750, 7, 4, 0, 0, 749, 748, 1, 0, 0, 0, 749, 750, 1, 0, 0, 0, 750, 751, 1, 0, 0, 0, 751, 752, 5, 55, 0, 0, 752, 149, 1, 0, 0, 0, 753, 755, 7, 4, 0, 0, 754, 753, 1, 0, 0, 0, 754, 755, 1, 0, 0, 0, 755, 756, 1, 0, 0, 0, 756, 757, 5, 54, 0, 0, 757, 151, 1, 0, 0, 0, 758, 759, 5, 53, 0, 0, 759, 153, 1, 0, 0, 0, 760, 761, 7, 7, 0, 0, 761, 155, 1, 0, 0, 0, 762, 763, 7, 8, 0, 0, 763, 764, 5, 114, 0, 0, 764, 765, 3, 158, 79, 0, 765, 766, 3, 160, 80, 0, 766, 157, 1, 0, 0, 0, 767, 768, 3, 28, 14, 0, 768, 159, 1, 0, 0, 0, 769, 770, 5, 74, 0, 0, 770, 775, 3, 162, 81, 0, 771, 772, 5, 62, 0, 0, 772, 774, 3, 162, 81, 0, 773, 771, 1, 0, 0, 0, 774, 777, 1, 0, 0, 0, 775, 773, 1, 0, 0, 0, 775, 776, 1, 0, 0, 0, 776, 161, 1, 0, 0, 0, 777, 775, 1, 0, 0, 0, 778, 779, 3, 128, 64, 0, 779, 163, 1, 0, 0, 0, 71, 175, 184, 215, 230, 236, 245, 251, 264, 268, 273, 279, 281, 295, 303, 307, 314, 320, 327, 335, 343, 351, 355, 359, 364, 375, 380, 384, 398, 409, 415, 429, 450, 458, 461, 466, 479, 485, 492, 503, 517, 529, 539, 545, 561, 570, 578, 583, 591, 593, 598, 605, 610, 615, 625, 631, 639, 641, 652, 659, 670, 675, 677, 689, 713, 724, 735, 740, 746, 749, 754, 775] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.java index f1d192fd0c180..0a0a113c6b394 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.java @@ -3257,8 +3257,8 @@ public IdentifierContext identifier() { return getRuleContext(IdentifierContext.class,0); } public TerminalNode ASSIGN() { return getToken(EsqlBaseParser.ASSIGN, 0); } - public ConstantContext constant() { - return getRuleContext(ConstantContext.class,0); + public PrimaryExpressionContext primaryExpression() { + return getRuleContext(PrimaryExpressionContext.class,0); } @SuppressWarnings("this-escape") public CommandOptionContext(ParserRuleContext parent, int invokingState) { @@ -3291,7 +3291,7 @@ public final CommandOptionContext commandOption() throws RecognitionException { setState(433); match(ASSIGN); setState(434); - constant(); + primaryExpression(0); } } catch (RecognitionException re) { @@ -7340,7 +7340,7 @@ private boolean primaryExpression_sempred(PrimaryExpressionContext _localctx, in "\u0000\u01ac\u01af\u0001\u0000\u0000\u0000\u01ad\u01ab\u0001\u0000\u0000"+ "\u0000\u01ad\u01ae\u0001\u0000\u0000\u0000\u01aeS\u0001\u0000\u0000\u0000"+ "\u01af\u01ad\u0001\u0000\u0000\u0000\u01b0\u01b1\u00034\u001a\u0000\u01b1"+ - "\u01b2\u0005:\u0000\u0000\u01b2\u01b3\u0003\u008eG\u0000\u01b3U\u0001"+ + "\u01b2\u0005:\u0000\u0000\u01b2\u01b3\u0003\u0084B\u0000\u01b3U\u0001"+ "\u0000\u0000\u0000\u01b4\u01b5\u0005\u0006\u0000\u0000\u01b5\u01b6\u0003"+ "X,\u0000\u01b6W\u0001\u0000\u0000\u0000\u01b7\u01b8\u0005a\u0000\u0000"+ "\u01b8\u01b9\u0003\u0002\u0001\u0000\u01b9\u01ba\u0005b\u0000\u0000\u01ba"+ diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java index 746dd315069f2..254f2ca2296a2 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java @@ -204,20 +204,21 @@ private void validateGrokPattern(Source source, Grok.Parser grokParser, String p public PlanFactory visitDissectCommand(EsqlBaseParser.DissectCommandContext ctx) { return p -> { String pattern = visitString(ctx.string()).fold(FoldContext.small() /* TODO remove me */).toString(); - Map options = visitCommandOptions(ctx.commandOptions()); + Map options = visitCommandOptions(ctx.commandOptions()); String appendSeparator = ""; - for (Map.Entry item : options.entrySet()) { + for (Map.Entry item : options.entrySet()) { if (item.getKey().equalsIgnoreCase("append_separator") == false) { throw new ParsingException(source(ctx), "Invalid option for dissect: [{}]", item.getKey()); } - if (item.getValue() instanceof String == false) { + Object foldedValue = item.getValue().fold(FoldContext.small()); + if (foldedValue instanceof String == false) { throw new ParsingException( source(ctx), "Invalid value for dissect append_separator: expected a string, but was [{}]", item.getValue() ); } - appendSeparator = (String) item.getValue(); + appendSeparator = (String) foldedValue; } Source src = source(ctx); @@ -252,13 +253,13 @@ public PlanFactory visitMvExpandCommand(EsqlBaseParser.MvExpandCommandContext ct } @Override - public Map visitCommandOptions(EsqlBaseParser.CommandOptionsContext ctx) { + public Map visitCommandOptions(EsqlBaseParser.CommandOptionsContext ctx) { if (ctx == null) { return Map.of(); } - Map result = new HashMap<>(); + Map result = new HashMap<>(); for (EsqlBaseParser.CommandOptionContext option : ctx.commandOption()) { - result.put(visitIdentifier(option.identifier()), expression(option.constant()).fold(FoldContext.small() /* TODO remove me */)); + result.put(visitIdentifier(option.identifier()), expression(option.primaryExpression())); } return result; } From 6734c6ff3a7f3c342cc9006edd33e342ef45ecae Mon Sep 17 00:00:00 2001 From: afoucret Date: Mon, 16 Jun 2025 18:31:33 +0200 Subject: [PATCH 02/10] Change the way inferenceId is passed to the command. --- .../src/main/resources/rerank.csv-spec | 12 ++-- .../esql/src/main/antlr/EsqlBaseParser.g4 | 2 +- .../xpack/esql/analysis/Analyzer.java | 6 +- .../xpack/esql/parser/EsqlBaseParser.interp | 2 +- .../xpack/esql/parser/EsqlBaseParser.java | 9 ++- .../xpack/esql/parser/LogicalPlanBuilder.java | 72 ++++++++++++++----- .../esql/plan/logical/inference/Rerank.java | 46 +++++++++--- .../xpack/esql/analysis/AnalyzerTests.java | 31 ++++---- .../esql/parser/StatementParserTests.java | 15 ++-- 9 files changed, 137 insertions(+), 58 deletions(-) diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/rerank.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/rerank.csv-spec index c4aea4664cca6..6c80d019e86d3 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/rerank.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/rerank.csv-spec @@ -9,7 +9,7 @@ required_capability: match_operator_colon FROM books METADATA _score | WHERE title:"war and peace" AND author:"Tolstoy" -| RERANK "war and peace" ON title WITH test_reranker +| RERANK "war and peace" ON title WITH inferenceId=test_reranker | KEEP book_no, title, author ; @@ -27,7 +27,7 @@ required_capability: match_operator_colon FROM books METADATA _score | WHERE title:"war and peace" AND author:"Tolstoy" -| RERANK "war and peace" ON title, author WITH test_reranker +| RERANK "war and peace" ON title, author inferenceId=test_reranker | KEEP book_no, title, author ; @@ -47,7 +47,7 @@ FROM books METADATA _score | WHERE title:"war and peace" AND author:"Tolstoy" | SORT _score DESC | LIMIT 3 -| RERANK "war and peace" ON title WITH test_reranker +| RERANK "war and peace" ON title inferenceId=test_reranker | KEEP book_no, title, author ; @@ -64,7 +64,7 @@ required_capability: match_operator_colon FROM books METADATA _score | WHERE title:"war and peace" AND author:"Tolstoy" -| RERANK "war and peace" ON title WITH test_reranker +| RERANK "war and peace" ON title inferenceId=test_reranker | KEEP book_no, title, author | LIMIT 3 ; @@ -82,7 +82,7 @@ required_capability: match_operator_colon FROM books | WHERE title:"war and peace" AND author:"Tolstoy" -| RERANK "war and peace" ON title WITH test_reranker +| RERANK "war and peace" ON title inferenceId=test_reranker | KEEP book_no, title, author | SORT author, title | LIMIT 3 @@ -105,7 +105,7 @@ FROM books METADATA _id, _index, _score | FORK ( WHERE title:"Tolkien" | SORT _score, _id DESC | LIMIT 3 ) ( WHERE author:"Tolkien" | SORT _score, _id DESC | LIMIT 3 ) | RRF -| RERANK "Tolkien" ON title WITH test_reranker +| RERANK "Tolkien" ON title inferenceId=test_reranker | LIMIT 2 | KEEP book_no, title, author ; diff --git a/x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4 b/x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4 index 0aeeda87ac2fa..091a37cc5f979 100644 --- a/x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4 +++ b/x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4 @@ -308,7 +308,7 @@ rrfCommand ; rerankCommand - : DEV_RERANK queryText=constant ON rerankFields (WITH inferenceId=identifierOrParameter)? + : DEV_RERANK queryText=constant ON rerankFields (WITH commandOptions)? ; completionCommand diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java index 7faab1493096a..927bb70934ee3 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java @@ -835,7 +835,11 @@ private LogicalPlan resolveRerank(Rerank rerank, List childrenOutput) if (rerank.scoreAttribute() instanceof UnresolvedAttribute ua) { Attribute resolved = resolveAttribute(ua, childrenOutput); if (resolved.resolved() == false || resolved.dataType() != DOUBLE) { - resolved = MetadataAttribute.create(Source.EMPTY, MetadataAttribute.SCORE); + if (ua.name().equals(MetadataAttribute.SCORE)) { + resolved = MetadataAttribute.create(Source.EMPTY, MetadataAttribute.SCORE); + } else { + resolved = new ReferenceAttribute(resolved.source(), resolved.name(), DOUBLE); + } } rerank = rerank.withScoreAttribute(resolved); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp index 9fc261a72c593..18b0a64659b58 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp @@ -368,4 +368,4 @@ joinPredicate atn: -[4, 1, 139, 781, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 2, 66, 7, 66, 2, 67, 7, 67, 2, 68, 7, 68, 2, 69, 7, 69, 2, 70, 7, 70, 2, 71, 7, 71, 2, 72, 7, 72, 2, 73, 7, 73, 2, 74, 7, 74, 2, 75, 7, 75, 2, 76, 7, 76, 2, 77, 7, 77, 2, 78, 7, 78, 2, 79, 7, 79, 2, 80, 7, 80, 2, 81, 7, 81, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 174, 8, 1, 10, 1, 12, 1, 177, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 185, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 216, 8, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 5, 7, 229, 8, 7, 10, 7, 12, 7, 232, 9, 7, 1, 8, 1, 8, 1, 8, 3, 8, 237, 8, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 5, 9, 244, 8, 9, 10, 9, 12, 9, 247, 9, 9, 1, 10, 1, 10, 1, 10, 3, 10, 252, 8, 10, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 5, 13, 263, 8, 13, 10, 13, 12, 13, 266, 9, 13, 1, 13, 3, 13, 269, 8, 13, 1, 14, 1, 14, 1, 14, 3, 14, 274, 8, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 280, 8, 14, 3, 14, 282, 8, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 5, 18, 294, 8, 18, 10, 18, 12, 18, 297, 9, 18, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 3, 20, 304, 8, 20, 1, 20, 1, 20, 3, 20, 308, 8, 20, 1, 21, 1, 21, 1, 21, 5, 21, 313, 8, 21, 10, 21, 12, 21, 316, 9, 21, 1, 22, 1, 22, 1, 22, 3, 22, 321, 8, 22, 1, 23, 1, 23, 1, 23, 5, 23, 326, 8, 23, 10, 23, 12, 23, 329, 9, 23, 1, 24, 1, 24, 1, 24, 5, 24, 334, 8, 24, 10, 24, 12, 24, 337, 9, 24, 1, 25, 1, 25, 1, 25, 5, 25, 342, 8, 25, 10, 25, 12, 25, 345, 9, 25, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 3, 27, 352, 8, 27, 1, 28, 1, 28, 3, 28, 356, 8, 28, 1, 29, 1, 29, 3, 29, 360, 8, 29, 1, 30, 1, 30, 1, 30, 3, 30, 365, 8, 30, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 5, 32, 374, 8, 32, 10, 32, 12, 32, 377, 9, 32, 1, 33, 1, 33, 3, 33, 381, 8, 33, 1, 33, 1, 33, 3, 33, 385, 8, 33, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 397, 8, 36, 10, 36, 12, 36, 400, 9, 36, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 3, 37, 410, 8, 37, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 416, 8, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 5, 41, 428, 8, 41, 10, 41, 12, 41, 431, 9, 41, 1, 42, 1, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 44, 1, 44, 1, 44, 1, 44, 1, 45, 1, 45, 1, 45, 1, 46, 1, 46, 1, 46, 1, 46, 3, 46, 451, 8, 46, 1, 46, 1, 46, 1, 46, 1, 46, 5, 46, 457, 8, 46, 10, 46, 12, 46, 460, 9, 46, 3, 46, 462, 8, 46, 1, 47, 1, 47, 1, 47, 3, 47, 467, 8, 47, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 1, 49, 1, 49, 3, 49, 480, 8, 49, 1, 50, 1, 50, 1, 50, 1, 50, 3, 50, 486, 8, 50, 1, 50, 1, 50, 1, 50, 1, 50, 1, 50, 3, 50, 493, 8, 50, 1, 51, 1, 51, 1, 51, 1, 52, 1, 52, 1, 52, 1, 53, 4, 53, 502, 8, 53, 11, 53, 12, 53, 503, 1, 54, 1, 54, 1, 54, 1, 54, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 5, 55, 516, 8, 55, 10, 55, 12, 55, 519, 9, 55, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 3, 56, 530, 8, 56, 1, 57, 1, 57, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 3, 58, 540, 8, 58, 1, 59, 1, 59, 1, 59, 1, 59, 3, 59, 546, 8, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 60, 1, 60, 1, 60, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 3, 61, 562, 8, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 5, 61, 569, 8, 61, 10, 61, 12, 61, 572, 9, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 3, 61, 579, 8, 61, 1, 61, 1, 61, 1, 61, 3, 61, 584, 8, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 5, 61, 592, 8, 61, 10, 61, 12, 61, 595, 9, 61, 1, 62, 1, 62, 3, 62, 599, 8, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 3, 62, 606, 8, 62, 1, 62, 1, 62, 1, 62, 3, 62, 611, 8, 62, 1, 63, 1, 63, 1, 63, 3, 63, 616, 8, 63, 1, 63, 1, 63, 1, 63, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 3, 64, 626, 8, 64, 1, 65, 1, 65, 1, 65, 1, 65, 3, 65, 632, 8, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 5, 65, 640, 8, 65, 10, 65, 12, 65, 643, 9, 65, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 3, 66, 653, 8, 66, 1, 66, 1, 66, 1, 66, 5, 66, 658, 8, 66, 10, 66, 12, 66, 661, 9, 66, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 5, 67, 669, 8, 67, 10, 67, 12, 67, 672, 9, 67, 1, 67, 1, 67, 3, 67, 676, 8, 67, 3, 67, 678, 8, 67, 1, 67, 1, 67, 1, 68, 1, 68, 1, 69, 1, 69, 1, 69, 1, 69, 5, 69, 688, 8, 69, 10, 69, 12, 69, 691, 9, 69, 1, 69, 1, 69, 1, 70, 1, 70, 1, 70, 1, 70, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 5, 71, 712, 8, 71, 10, 71, 12, 71, 715, 9, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 5, 71, 723, 8, 71, 10, 71, 12, 71, 726, 9, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 5, 71, 734, 8, 71, 10, 71, 12, 71, 737, 9, 71, 1, 71, 1, 71, 3, 71, 741, 8, 71, 1, 72, 1, 72, 1, 73, 1, 73, 3, 73, 747, 8, 73, 1, 74, 3, 74, 750, 8, 74, 1, 74, 1, 74, 1, 75, 3, 75, 755, 8, 75, 1, 75, 1, 75, 1, 76, 1, 76, 1, 77, 1, 77, 1, 78, 1, 78, 1, 78, 1, 78, 1, 78, 1, 79, 1, 79, 1, 80, 1, 80, 1, 80, 1, 80, 5, 80, 774, 8, 80, 10, 80, 12, 80, 777, 9, 80, 1, 81, 1, 81, 1, 81, 0, 5, 2, 110, 122, 130, 132, 82, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 0, 9, 2, 0, 53, 53, 107, 107, 1, 0, 101, 102, 2, 0, 57, 57, 63, 63, 2, 0, 66, 66, 69, 69, 1, 0, 87, 88, 1, 0, 89, 91, 2, 0, 65, 65, 78, 78, 2, 0, 80, 80, 82, 86, 2, 0, 22, 22, 24, 25, 816, 0, 164, 1, 0, 0, 0, 2, 167, 1, 0, 0, 0, 4, 184, 1, 0, 0, 0, 6, 215, 1, 0, 0, 0, 8, 217, 1, 0, 0, 0, 10, 220, 1, 0, 0, 0, 12, 222, 1, 0, 0, 0, 14, 225, 1, 0, 0, 0, 16, 236, 1, 0, 0, 0, 18, 240, 1, 0, 0, 0, 20, 248, 1, 0, 0, 0, 22, 253, 1, 0, 0, 0, 24, 256, 1, 0, 0, 0, 26, 259, 1, 0, 0, 0, 28, 281, 1, 0, 0, 0, 30, 283, 1, 0, 0, 0, 32, 285, 1, 0, 0, 0, 34, 287, 1, 0, 0, 0, 36, 289, 1, 0, 0, 0, 38, 298, 1, 0, 0, 0, 40, 301, 1, 0, 0, 0, 42, 309, 1, 0, 0, 0, 44, 317, 1, 0, 0, 0, 46, 322, 1, 0, 0, 0, 48, 330, 1, 0, 0, 0, 50, 338, 1, 0, 0, 0, 52, 346, 1, 0, 0, 0, 54, 351, 1, 0, 0, 0, 56, 355, 1, 0, 0, 0, 58, 359, 1, 0, 0, 0, 60, 364, 1, 0, 0, 0, 62, 366, 1, 0, 0, 0, 64, 369, 1, 0, 0, 0, 66, 378, 1, 0, 0, 0, 68, 386, 1, 0, 0, 0, 70, 389, 1, 0, 0, 0, 72, 392, 1, 0, 0, 0, 74, 409, 1, 0, 0, 0, 76, 411, 1, 0, 0, 0, 78, 417, 1, 0, 0, 0, 80, 421, 1, 0, 0, 0, 82, 424, 1, 0, 0, 0, 84, 432, 1, 0, 0, 0, 86, 436, 1, 0, 0, 0, 88, 439, 1, 0, 0, 0, 90, 443, 1, 0, 0, 0, 92, 446, 1, 0, 0, 0, 94, 466, 1, 0, 0, 0, 96, 470, 1, 0, 0, 0, 98, 475, 1, 0, 0, 0, 100, 481, 1, 0, 0, 0, 102, 494, 1, 0, 0, 0, 104, 497, 1, 0, 0, 0, 106, 501, 1, 0, 0, 0, 108, 505, 1, 0, 0, 0, 110, 509, 1, 0, 0, 0, 112, 529, 1, 0, 0, 0, 114, 531, 1, 0, 0, 0, 116, 533, 1, 0, 0, 0, 118, 541, 1, 0, 0, 0, 120, 551, 1, 0, 0, 0, 122, 583, 1, 0, 0, 0, 124, 610, 1, 0, 0, 0, 126, 612, 1, 0, 0, 0, 128, 625, 1, 0, 0, 0, 130, 631, 1, 0, 0, 0, 132, 652, 1, 0, 0, 0, 134, 662, 1, 0, 0, 0, 136, 681, 1, 0, 0, 0, 138, 683, 1, 0, 0, 0, 140, 694, 1, 0, 0, 0, 142, 740, 1, 0, 0, 0, 144, 742, 1, 0, 0, 0, 146, 746, 1, 0, 0, 0, 148, 749, 1, 0, 0, 0, 150, 754, 1, 0, 0, 0, 152, 758, 1, 0, 0, 0, 154, 760, 1, 0, 0, 0, 156, 762, 1, 0, 0, 0, 158, 767, 1, 0, 0, 0, 160, 769, 1, 0, 0, 0, 162, 778, 1, 0, 0, 0, 164, 165, 3, 2, 1, 0, 165, 166, 5, 0, 0, 1, 166, 1, 1, 0, 0, 0, 167, 168, 6, 1, -1, 0, 168, 169, 3, 4, 2, 0, 169, 175, 1, 0, 0, 0, 170, 171, 10, 1, 0, 0, 171, 172, 5, 52, 0, 0, 172, 174, 3, 6, 3, 0, 173, 170, 1, 0, 0, 0, 174, 177, 1, 0, 0, 0, 175, 173, 1, 0, 0, 0, 175, 176, 1, 0, 0, 0, 176, 3, 1, 0, 0, 0, 177, 175, 1, 0, 0, 0, 178, 185, 3, 86, 43, 0, 179, 185, 3, 22, 11, 0, 180, 185, 3, 12, 6, 0, 181, 185, 3, 90, 45, 0, 182, 183, 4, 2, 1, 0, 183, 185, 3, 24, 12, 0, 184, 178, 1, 0, 0, 0, 184, 179, 1, 0, 0, 0, 184, 180, 1, 0, 0, 0, 184, 181, 1, 0, 0, 0, 184, 182, 1, 0, 0, 0, 185, 5, 1, 0, 0, 0, 186, 216, 3, 38, 19, 0, 187, 216, 3, 8, 4, 0, 188, 216, 3, 68, 34, 0, 189, 216, 3, 62, 31, 0, 190, 216, 3, 40, 20, 0, 191, 216, 3, 64, 32, 0, 192, 216, 3, 70, 35, 0, 193, 216, 3, 72, 36, 0, 194, 216, 3, 76, 38, 0, 195, 216, 3, 78, 39, 0, 196, 216, 3, 92, 46, 0, 197, 216, 3, 80, 40, 0, 198, 216, 3, 156, 78, 0, 199, 216, 3, 100, 50, 0, 200, 216, 3, 118, 59, 0, 201, 202, 4, 3, 2, 0, 202, 216, 3, 98, 49, 0, 203, 204, 4, 3, 3, 0, 204, 216, 3, 96, 48, 0, 205, 206, 4, 3, 4, 0, 206, 216, 3, 102, 51, 0, 207, 208, 4, 3, 5, 0, 208, 216, 3, 104, 52, 0, 209, 210, 4, 3, 6, 0, 210, 216, 3, 116, 58, 0, 211, 212, 4, 3, 7, 0, 212, 216, 3, 114, 57, 0, 213, 214, 4, 3, 8, 0, 214, 216, 3, 120, 60, 0, 215, 186, 1, 0, 0, 0, 215, 187, 1, 0, 0, 0, 215, 188, 1, 0, 0, 0, 215, 189, 1, 0, 0, 0, 215, 190, 1, 0, 0, 0, 215, 191, 1, 0, 0, 0, 215, 192, 1, 0, 0, 0, 215, 193, 1, 0, 0, 0, 215, 194, 1, 0, 0, 0, 215, 195, 1, 0, 0, 0, 215, 196, 1, 0, 0, 0, 215, 197, 1, 0, 0, 0, 215, 198, 1, 0, 0, 0, 215, 199, 1, 0, 0, 0, 215, 200, 1, 0, 0, 0, 215, 201, 1, 0, 0, 0, 215, 203, 1, 0, 0, 0, 215, 205, 1, 0, 0, 0, 215, 207, 1, 0, 0, 0, 215, 209, 1, 0, 0, 0, 215, 211, 1, 0, 0, 0, 215, 213, 1, 0, 0, 0, 216, 7, 1, 0, 0, 0, 217, 218, 5, 15, 0, 0, 218, 219, 3, 122, 61, 0, 219, 9, 1, 0, 0, 0, 220, 221, 3, 52, 26, 0, 221, 11, 1, 0, 0, 0, 222, 223, 5, 12, 0, 0, 223, 224, 3, 14, 7, 0, 224, 13, 1, 0, 0, 0, 225, 230, 3, 16, 8, 0, 226, 227, 5, 62, 0, 0, 227, 229, 3, 16, 8, 0, 228, 226, 1, 0, 0, 0, 229, 232, 1, 0, 0, 0, 230, 228, 1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 15, 1, 0, 0, 0, 232, 230, 1, 0, 0, 0, 233, 234, 3, 46, 23, 0, 234, 235, 5, 58, 0, 0, 235, 237, 1, 0, 0, 0, 236, 233, 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 238, 1, 0, 0, 0, 238, 239, 3, 122, 61, 0, 239, 17, 1, 0, 0, 0, 240, 245, 3, 20, 10, 0, 241, 242, 5, 62, 0, 0, 242, 244, 3, 20, 10, 0, 243, 241, 1, 0, 0, 0, 244, 247, 1, 0, 0, 0, 245, 243, 1, 0, 0, 0, 245, 246, 1, 0, 0, 0, 246, 19, 1, 0, 0, 0, 247, 245, 1, 0, 0, 0, 248, 251, 3, 46, 23, 0, 249, 250, 5, 58, 0, 0, 250, 252, 3, 122, 61, 0, 251, 249, 1, 0, 0, 0, 251, 252, 1, 0, 0, 0, 252, 21, 1, 0, 0, 0, 253, 254, 5, 19, 0, 0, 254, 255, 3, 26, 13, 0, 255, 23, 1, 0, 0, 0, 256, 257, 5, 20, 0, 0, 257, 258, 3, 26, 13, 0, 258, 25, 1, 0, 0, 0, 259, 264, 3, 28, 14, 0, 260, 261, 5, 62, 0, 0, 261, 263, 3, 28, 14, 0, 262, 260, 1, 0, 0, 0, 263, 266, 1, 0, 0, 0, 264, 262, 1, 0, 0, 0, 264, 265, 1, 0, 0, 0, 265, 268, 1, 0, 0, 0, 266, 264, 1, 0, 0, 0, 267, 269, 3, 36, 18, 0, 268, 267, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, 27, 1, 0, 0, 0, 270, 271, 3, 30, 15, 0, 271, 272, 5, 61, 0, 0, 272, 274, 1, 0, 0, 0, 273, 270, 1, 0, 0, 0, 273, 274, 1, 0, 0, 0, 274, 275, 1, 0, 0, 0, 275, 282, 3, 34, 17, 0, 276, 279, 3, 34, 17, 0, 277, 278, 5, 60, 0, 0, 278, 280, 3, 32, 16, 0, 279, 277, 1, 0, 0, 0, 279, 280, 1, 0, 0, 0, 280, 282, 1, 0, 0, 0, 281, 273, 1, 0, 0, 0, 281, 276, 1, 0, 0, 0, 282, 29, 1, 0, 0, 0, 283, 284, 7, 0, 0, 0, 284, 31, 1, 0, 0, 0, 285, 286, 7, 0, 0, 0, 286, 33, 1, 0, 0, 0, 287, 288, 7, 0, 0, 0, 288, 35, 1, 0, 0, 0, 289, 290, 5, 106, 0, 0, 290, 295, 5, 107, 0, 0, 291, 292, 5, 62, 0, 0, 292, 294, 5, 107, 0, 0, 293, 291, 1, 0, 0, 0, 294, 297, 1, 0, 0, 0, 295, 293, 1, 0, 0, 0, 295, 296, 1, 0, 0, 0, 296, 37, 1, 0, 0, 0, 297, 295, 1, 0, 0, 0, 298, 299, 5, 9, 0, 0, 299, 300, 3, 14, 7, 0, 300, 39, 1, 0, 0, 0, 301, 303, 5, 14, 0, 0, 302, 304, 3, 42, 21, 0, 303, 302, 1, 0, 0, 0, 303, 304, 1, 0, 0, 0, 304, 307, 1, 0, 0, 0, 305, 306, 5, 59, 0, 0, 306, 308, 3, 14, 7, 0, 307, 305, 1, 0, 0, 0, 307, 308, 1, 0, 0, 0, 308, 41, 1, 0, 0, 0, 309, 314, 3, 44, 22, 0, 310, 311, 5, 62, 0, 0, 311, 313, 3, 44, 22, 0, 312, 310, 1, 0, 0, 0, 313, 316, 1, 0, 0, 0, 314, 312, 1, 0, 0, 0, 314, 315, 1, 0, 0, 0, 315, 43, 1, 0, 0, 0, 316, 314, 1, 0, 0, 0, 317, 320, 3, 16, 8, 0, 318, 319, 5, 15, 0, 0, 319, 321, 3, 122, 61, 0, 320, 318, 1, 0, 0, 0, 320, 321, 1, 0, 0, 0, 321, 45, 1, 0, 0, 0, 322, 327, 3, 60, 30, 0, 323, 324, 5, 64, 0, 0, 324, 326, 3, 60, 30, 0, 325, 323, 1, 0, 0, 0, 326, 329, 1, 0, 0, 0, 327, 325, 1, 0, 0, 0, 327, 328, 1, 0, 0, 0, 328, 47, 1, 0, 0, 0, 329, 327, 1, 0, 0, 0, 330, 335, 3, 54, 27, 0, 331, 332, 5, 64, 0, 0, 332, 334, 3, 54, 27, 0, 333, 331, 1, 0, 0, 0, 334, 337, 1, 0, 0, 0, 335, 333, 1, 0, 0, 0, 335, 336, 1, 0, 0, 0, 336, 49, 1, 0, 0, 0, 337, 335, 1, 0, 0, 0, 338, 343, 3, 48, 24, 0, 339, 340, 5, 62, 0, 0, 340, 342, 3, 48, 24, 0, 341, 339, 1, 0, 0, 0, 342, 345, 1, 0, 0, 0, 343, 341, 1, 0, 0, 0, 343, 344, 1, 0, 0, 0, 344, 51, 1, 0, 0, 0, 345, 343, 1, 0, 0, 0, 346, 347, 7, 1, 0, 0, 347, 53, 1, 0, 0, 0, 348, 352, 5, 128, 0, 0, 349, 352, 3, 56, 28, 0, 350, 352, 3, 58, 29, 0, 351, 348, 1, 0, 0, 0, 351, 349, 1, 0, 0, 0, 351, 350, 1, 0, 0, 0, 352, 55, 1, 0, 0, 0, 353, 356, 5, 76, 0, 0, 354, 356, 5, 95, 0, 0, 355, 353, 1, 0, 0, 0, 355, 354, 1, 0, 0, 0, 356, 57, 1, 0, 0, 0, 357, 360, 5, 94, 0, 0, 358, 360, 5, 96, 0, 0, 359, 357, 1, 0, 0, 0, 359, 358, 1, 0, 0, 0, 360, 59, 1, 0, 0, 0, 361, 365, 3, 52, 26, 0, 362, 365, 3, 56, 28, 0, 363, 365, 3, 58, 29, 0, 364, 361, 1, 0, 0, 0, 364, 362, 1, 0, 0, 0, 364, 363, 1, 0, 0, 0, 365, 61, 1, 0, 0, 0, 366, 367, 5, 11, 0, 0, 367, 368, 3, 142, 71, 0, 368, 63, 1, 0, 0, 0, 369, 370, 5, 13, 0, 0, 370, 375, 3, 66, 33, 0, 371, 372, 5, 62, 0, 0, 372, 374, 3, 66, 33, 0, 373, 371, 1, 0, 0, 0, 374, 377, 1, 0, 0, 0, 375, 373, 1, 0, 0, 0, 375, 376, 1, 0, 0, 0, 376, 65, 1, 0, 0, 0, 377, 375, 1, 0, 0, 0, 378, 380, 3, 122, 61, 0, 379, 381, 7, 2, 0, 0, 380, 379, 1, 0, 0, 0, 380, 381, 1, 0, 0, 0, 381, 384, 1, 0, 0, 0, 382, 383, 5, 73, 0, 0, 383, 385, 7, 3, 0, 0, 384, 382, 1, 0, 0, 0, 384, 385, 1, 0, 0, 0, 385, 67, 1, 0, 0, 0, 386, 387, 5, 29, 0, 0, 387, 388, 3, 50, 25, 0, 388, 69, 1, 0, 0, 0, 389, 390, 5, 28, 0, 0, 390, 391, 3, 50, 25, 0, 391, 71, 1, 0, 0, 0, 392, 393, 5, 32, 0, 0, 393, 398, 3, 74, 37, 0, 394, 395, 5, 62, 0, 0, 395, 397, 3, 74, 37, 0, 396, 394, 1, 0, 0, 0, 397, 400, 1, 0, 0, 0, 398, 396, 1, 0, 0, 0, 398, 399, 1, 0, 0, 0, 399, 73, 1, 0, 0, 0, 400, 398, 1, 0, 0, 0, 401, 402, 3, 48, 24, 0, 402, 403, 5, 132, 0, 0, 403, 404, 3, 48, 24, 0, 404, 410, 1, 0, 0, 0, 405, 406, 3, 48, 24, 0, 406, 407, 5, 58, 0, 0, 407, 408, 3, 48, 24, 0, 408, 410, 1, 0, 0, 0, 409, 401, 1, 0, 0, 0, 409, 405, 1, 0, 0, 0, 410, 75, 1, 0, 0, 0, 411, 412, 5, 8, 0, 0, 412, 413, 3, 132, 66, 0, 413, 415, 3, 152, 76, 0, 414, 416, 3, 82, 41, 0, 415, 414, 1, 0, 0, 0, 415, 416, 1, 0, 0, 0, 416, 77, 1, 0, 0, 0, 417, 418, 5, 10, 0, 0, 418, 419, 3, 132, 66, 0, 419, 420, 3, 152, 76, 0, 420, 79, 1, 0, 0, 0, 421, 422, 5, 27, 0, 0, 422, 423, 3, 46, 23, 0, 423, 81, 1, 0, 0, 0, 424, 429, 3, 84, 42, 0, 425, 426, 5, 62, 0, 0, 426, 428, 3, 84, 42, 0, 427, 425, 1, 0, 0, 0, 428, 431, 1, 0, 0, 0, 429, 427, 1, 0, 0, 0, 429, 430, 1, 0, 0, 0, 430, 83, 1, 0, 0, 0, 431, 429, 1, 0, 0, 0, 432, 433, 3, 52, 26, 0, 433, 434, 5, 58, 0, 0, 434, 435, 3, 132, 66, 0, 435, 85, 1, 0, 0, 0, 436, 437, 5, 6, 0, 0, 437, 438, 3, 88, 44, 0, 438, 87, 1, 0, 0, 0, 439, 440, 5, 97, 0, 0, 440, 441, 3, 2, 1, 0, 441, 442, 5, 98, 0, 0, 442, 89, 1, 0, 0, 0, 443, 444, 5, 33, 0, 0, 444, 445, 5, 136, 0, 0, 445, 91, 1, 0, 0, 0, 446, 447, 5, 5, 0, 0, 447, 450, 5, 38, 0, 0, 448, 449, 5, 74, 0, 0, 449, 451, 3, 48, 24, 0, 450, 448, 1, 0, 0, 0, 450, 451, 1, 0, 0, 0, 451, 461, 1, 0, 0, 0, 452, 453, 5, 79, 0, 0, 453, 458, 3, 94, 47, 0, 454, 455, 5, 62, 0, 0, 455, 457, 3, 94, 47, 0, 456, 454, 1, 0, 0, 0, 457, 460, 1, 0, 0, 0, 458, 456, 1, 0, 0, 0, 458, 459, 1, 0, 0, 0, 459, 462, 1, 0, 0, 0, 460, 458, 1, 0, 0, 0, 461, 452, 1, 0, 0, 0, 461, 462, 1, 0, 0, 0, 462, 93, 1, 0, 0, 0, 463, 464, 3, 48, 24, 0, 464, 465, 5, 58, 0, 0, 465, 467, 1, 0, 0, 0, 466, 463, 1, 0, 0, 0, 466, 467, 1, 0, 0, 0, 467, 468, 1, 0, 0, 0, 468, 469, 3, 48, 24, 0, 469, 95, 1, 0, 0, 0, 470, 471, 5, 26, 0, 0, 471, 472, 3, 28, 14, 0, 472, 473, 5, 74, 0, 0, 473, 474, 3, 50, 25, 0, 474, 97, 1, 0, 0, 0, 475, 476, 5, 16, 0, 0, 476, 479, 3, 42, 21, 0, 477, 478, 5, 59, 0, 0, 478, 480, 3, 14, 7, 0, 479, 477, 1, 0, 0, 0, 479, 480, 1, 0, 0, 0, 480, 99, 1, 0, 0, 0, 481, 482, 5, 4, 0, 0, 482, 485, 3, 46, 23, 0, 483, 484, 5, 74, 0, 0, 484, 486, 3, 46, 23, 0, 485, 483, 1, 0, 0, 0, 485, 486, 1, 0, 0, 0, 486, 492, 1, 0, 0, 0, 487, 488, 5, 132, 0, 0, 488, 489, 3, 46, 23, 0, 489, 490, 5, 62, 0, 0, 490, 491, 3, 46, 23, 0, 491, 493, 1, 0, 0, 0, 492, 487, 1, 0, 0, 0, 492, 493, 1, 0, 0, 0, 493, 101, 1, 0, 0, 0, 494, 495, 5, 30, 0, 0, 495, 496, 3, 50, 25, 0, 496, 103, 1, 0, 0, 0, 497, 498, 5, 21, 0, 0, 498, 499, 3, 106, 53, 0, 499, 105, 1, 0, 0, 0, 500, 502, 3, 108, 54, 0, 501, 500, 1, 0, 0, 0, 502, 503, 1, 0, 0, 0, 503, 501, 1, 0, 0, 0, 503, 504, 1, 0, 0, 0, 504, 107, 1, 0, 0, 0, 505, 506, 5, 99, 0, 0, 506, 507, 3, 110, 55, 0, 507, 508, 5, 100, 0, 0, 508, 109, 1, 0, 0, 0, 509, 510, 6, 55, -1, 0, 510, 511, 3, 112, 56, 0, 511, 517, 1, 0, 0, 0, 512, 513, 10, 1, 0, 0, 513, 514, 5, 52, 0, 0, 514, 516, 3, 112, 56, 0, 515, 512, 1, 0, 0, 0, 516, 519, 1, 0, 0, 0, 517, 515, 1, 0, 0, 0, 517, 518, 1, 0, 0, 0, 518, 111, 1, 0, 0, 0, 519, 517, 1, 0, 0, 0, 520, 530, 3, 38, 19, 0, 521, 530, 3, 8, 4, 0, 522, 530, 3, 62, 31, 0, 523, 530, 3, 40, 20, 0, 524, 530, 3, 64, 32, 0, 525, 530, 3, 76, 38, 0, 526, 530, 3, 100, 50, 0, 527, 530, 3, 118, 59, 0, 528, 530, 3, 78, 39, 0, 529, 520, 1, 0, 0, 0, 529, 521, 1, 0, 0, 0, 529, 522, 1, 0, 0, 0, 529, 523, 1, 0, 0, 0, 529, 524, 1, 0, 0, 0, 529, 525, 1, 0, 0, 0, 529, 526, 1, 0, 0, 0, 529, 527, 1, 0, 0, 0, 529, 528, 1, 0, 0, 0, 530, 113, 1, 0, 0, 0, 531, 532, 5, 31, 0, 0, 532, 115, 1, 0, 0, 0, 533, 534, 5, 17, 0, 0, 534, 535, 3, 142, 71, 0, 535, 536, 5, 74, 0, 0, 536, 539, 3, 18, 9, 0, 537, 538, 5, 79, 0, 0, 538, 540, 3, 60, 30, 0, 539, 537, 1, 0, 0, 0, 539, 540, 1, 0, 0, 0, 540, 117, 1, 0, 0, 0, 541, 545, 5, 7, 0, 0, 542, 543, 3, 46, 23, 0, 543, 544, 5, 58, 0, 0, 544, 546, 1, 0, 0, 0, 545, 542, 1, 0, 0, 0, 545, 546, 1, 0, 0, 0, 546, 547, 1, 0, 0, 0, 547, 548, 3, 132, 66, 0, 548, 549, 5, 79, 0, 0, 549, 550, 3, 60, 30, 0, 550, 119, 1, 0, 0, 0, 551, 552, 5, 18, 0, 0, 552, 553, 3, 148, 74, 0, 553, 121, 1, 0, 0, 0, 554, 555, 6, 61, -1, 0, 555, 556, 5, 71, 0, 0, 556, 584, 3, 122, 61, 8, 557, 584, 3, 128, 64, 0, 558, 584, 3, 124, 62, 0, 559, 561, 3, 128, 64, 0, 560, 562, 5, 71, 0, 0, 561, 560, 1, 0, 0, 0, 561, 562, 1, 0, 0, 0, 562, 563, 1, 0, 0, 0, 563, 564, 5, 67, 0, 0, 564, 565, 5, 99, 0, 0, 565, 570, 3, 128, 64, 0, 566, 567, 5, 62, 0, 0, 567, 569, 3, 128, 64, 0, 568, 566, 1, 0, 0, 0, 569, 572, 1, 0, 0, 0, 570, 568, 1, 0, 0, 0, 570, 571, 1, 0, 0, 0, 571, 573, 1, 0, 0, 0, 572, 570, 1, 0, 0, 0, 573, 574, 5, 100, 0, 0, 574, 584, 1, 0, 0, 0, 575, 576, 3, 128, 64, 0, 576, 578, 5, 68, 0, 0, 577, 579, 5, 71, 0, 0, 578, 577, 1, 0, 0, 0, 578, 579, 1, 0, 0, 0, 579, 580, 1, 0, 0, 0, 580, 581, 5, 72, 0, 0, 581, 584, 1, 0, 0, 0, 582, 584, 3, 126, 63, 0, 583, 554, 1, 0, 0, 0, 583, 557, 1, 0, 0, 0, 583, 558, 1, 0, 0, 0, 583, 559, 1, 0, 0, 0, 583, 575, 1, 0, 0, 0, 583, 582, 1, 0, 0, 0, 584, 593, 1, 0, 0, 0, 585, 586, 10, 5, 0, 0, 586, 587, 5, 56, 0, 0, 587, 592, 3, 122, 61, 6, 588, 589, 10, 4, 0, 0, 589, 590, 5, 75, 0, 0, 590, 592, 3, 122, 61, 5, 591, 585, 1, 0, 0, 0, 591, 588, 1, 0, 0, 0, 592, 595, 1, 0, 0, 0, 593, 591, 1, 0, 0, 0, 593, 594, 1, 0, 0, 0, 594, 123, 1, 0, 0, 0, 595, 593, 1, 0, 0, 0, 596, 598, 3, 128, 64, 0, 597, 599, 5, 71, 0, 0, 598, 597, 1, 0, 0, 0, 598, 599, 1, 0, 0, 0, 599, 600, 1, 0, 0, 0, 600, 601, 5, 70, 0, 0, 601, 602, 3, 152, 76, 0, 602, 611, 1, 0, 0, 0, 603, 605, 3, 128, 64, 0, 604, 606, 5, 71, 0, 0, 605, 604, 1, 0, 0, 0, 605, 606, 1, 0, 0, 0, 606, 607, 1, 0, 0, 0, 607, 608, 5, 77, 0, 0, 608, 609, 3, 152, 76, 0, 609, 611, 1, 0, 0, 0, 610, 596, 1, 0, 0, 0, 610, 603, 1, 0, 0, 0, 611, 125, 1, 0, 0, 0, 612, 615, 3, 46, 23, 0, 613, 614, 5, 60, 0, 0, 614, 616, 3, 10, 5, 0, 615, 613, 1, 0, 0, 0, 615, 616, 1, 0, 0, 0, 616, 617, 1, 0, 0, 0, 617, 618, 5, 61, 0, 0, 618, 619, 3, 142, 71, 0, 619, 127, 1, 0, 0, 0, 620, 626, 3, 130, 65, 0, 621, 622, 3, 130, 65, 0, 622, 623, 3, 154, 77, 0, 623, 624, 3, 130, 65, 0, 624, 626, 1, 0, 0, 0, 625, 620, 1, 0, 0, 0, 625, 621, 1, 0, 0, 0, 626, 129, 1, 0, 0, 0, 627, 628, 6, 65, -1, 0, 628, 632, 3, 132, 66, 0, 629, 630, 7, 4, 0, 0, 630, 632, 3, 130, 65, 3, 631, 627, 1, 0, 0, 0, 631, 629, 1, 0, 0, 0, 632, 641, 1, 0, 0, 0, 633, 634, 10, 2, 0, 0, 634, 635, 7, 5, 0, 0, 635, 640, 3, 130, 65, 3, 636, 637, 10, 1, 0, 0, 637, 638, 7, 4, 0, 0, 638, 640, 3, 130, 65, 2, 639, 633, 1, 0, 0, 0, 639, 636, 1, 0, 0, 0, 640, 643, 1, 0, 0, 0, 641, 639, 1, 0, 0, 0, 641, 642, 1, 0, 0, 0, 642, 131, 1, 0, 0, 0, 643, 641, 1, 0, 0, 0, 644, 645, 6, 66, -1, 0, 645, 653, 3, 142, 71, 0, 646, 653, 3, 46, 23, 0, 647, 653, 3, 134, 67, 0, 648, 649, 5, 99, 0, 0, 649, 650, 3, 122, 61, 0, 650, 651, 5, 100, 0, 0, 651, 653, 1, 0, 0, 0, 652, 644, 1, 0, 0, 0, 652, 646, 1, 0, 0, 0, 652, 647, 1, 0, 0, 0, 652, 648, 1, 0, 0, 0, 653, 659, 1, 0, 0, 0, 654, 655, 10, 1, 0, 0, 655, 656, 5, 60, 0, 0, 656, 658, 3, 10, 5, 0, 657, 654, 1, 0, 0, 0, 658, 661, 1, 0, 0, 0, 659, 657, 1, 0, 0, 0, 659, 660, 1, 0, 0, 0, 660, 133, 1, 0, 0, 0, 661, 659, 1, 0, 0, 0, 662, 663, 3, 136, 68, 0, 663, 677, 5, 99, 0, 0, 664, 678, 5, 89, 0, 0, 665, 670, 3, 122, 61, 0, 666, 667, 5, 62, 0, 0, 667, 669, 3, 122, 61, 0, 668, 666, 1, 0, 0, 0, 669, 672, 1, 0, 0, 0, 670, 668, 1, 0, 0, 0, 670, 671, 1, 0, 0, 0, 671, 675, 1, 0, 0, 0, 672, 670, 1, 0, 0, 0, 673, 674, 5, 62, 0, 0, 674, 676, 3, 138, 69, 0, 675, 673, 1, 0, 0, 0, 675, 676, 1, 0, 0, 0, 676, 678, 1, 0, 0, 0, 677, 664, 1, 0, 0, 0, 677, 665, 1, 0, 0, 0, 677, 678, 1, 0, 0, 0, 678, 679, 1, 0, 0, 0, 679, 680, 5, 100, 0, 0, 680, 135, 1, 0, 0, 0, 681, 682, 3, 60, 30, 0, 682, 137, 1, 0, 0, 0, 683, 684, 5, 92, 0, 0, 684, 689, 3, 140, 70, 0, 685, 686, 5, 62, 0, 0, 686, 688, 3, 140, 70, 0, 687, 685, 1, 0, 0, 0, 688, 691, 1, 0, 0, 0, 689, 687, 1, 0, 0, 0, 689, 690, 1, 0, 0, 0, 690, 692, 1, 0, 0, 0, 691, 689, 1, 0, 0, 0, 692, 693, 5, 93, 0, 0, 693, 139, 1, 0, 0, 0, 694, 695, 3, 152, 76, 0, 695, 696, 5, 61, 0, 0, 696, 697, 3, 142, 71, 0, 697, 141, 1, 0, 0, 0, 698, 741, 5, 72, 0, 0, 699, 700, 3, 150, 75, 0, 700, 701, 5, 101, 0, 0, 701, 741, 1, 0, 0, 0, 702, 741, 3, 148, 74, 0, 703, 741, 3, 150, 75, 0, 704, 741, 3, 144, 72, 0, 705, 741, 3, 56, 28, 0, 706, 741, 3, 152, 76, 0, 707, 708, 5, 97, 0, 0, 708, 713, 3, 146, 73, 0, 709, 710, 5, 62, 0, 0, 710, 712, 3, 146, 73, 0, 711, 709, 1, 0, 0, 0, 712, 715, 1, 0, 0, 0, 713, 711, 1, 0, 0, 0, 713, 714, 1, 0, 0, 0, 714, 716, 1, 0, 0, 0, 715, 713, 1, 0, 0, 0, 716, 717, 5, 98, 0, 0, 717, 741, 1, 0, 0, 0, 718, 719, 5, 97, 0, 0, 719, 724, 3, 144, 72, 0, 720, 721, 5, 62, 0, 0, 721, 723, 3, 144, 72, 0, 722, 720, 1, 0, 0, 0, 723, 726, 1, 0, 0, 0, 724, 722, 1, 0, 0, 0, 724, 725, 1, 0, 0, 0, 725, 727, 1, 0, 0, 0, 726, 724, 1, 0, 0, 0, 727, 728, 5, 98, 0, 0, 728, 741, 1, 0, 0, 0, 729, 730, 5, 97, 0, 0, 730, 735, 3, 152, 76, 0, 731, 732, 5, 62, 0, 0, 732, 734, 3, 152, 76, 0, 733, 731, 1, 0, 0, 0, 734, 737, 1, 0, 0, 0, 735, 733, 1, 0, 0, 0, 735, 736, 1, 0, 0, 0, 736, 738, 1, 0, 0, 0, 737, 735, 1, 0, 0, 0, 738, 739, 5, 98, 0, 0, 739, 741, 1, 0, 0, 0, 740, 698, 1, 0, 0, 0, 740, 699, 1, 0, 0, 0, 740, 702, 1, 0, 0, 0, 740, 703, 1, 0, 0, 0, 740, 704, 1, 0, 0, 0, 740, 705, 1, 0, 0, 0, 740, 706, 1, 0, 0, 0, 740, 707, 1, 0, 0, 0, 740, 718, 1, 0, 0, 0, 740, 729, 1, 0, 0, 0, 741, 143, 1, 0, 0, 0, 742, 743, 7, 6, 0, 0, 743, 145, 1, 0, 0, 0, 744, 747, 3, 148, 74, 0, 745, 747, 3, 150, 75, 0, 746, 744, 1, 0, 0, 0, 746, 745, 1, 0, 0, 0, 747, 147, 1, 0, 0, 0, 748, 750, 7, 4, 0, 0, 749, 748, 1, 0, 0, 0, 749, 750, 1, 0, 0, 0, 750, 751, 1, 0, 0, 0, 751, 752, 5, 55, 0, 0, 752, 149, 1, 0, 0, 0, 753, 755, 7, 4, 0, 0, 754, 753, 1, 0, 0, 0, 754, 755, 1, 0, 0, 0, 755, 756, 1, 0, 0, 0, 756, 757, 5, 54, 0, 0, 757, 151, 1, 0, 0, 0, 758, 759, 5, 53, 0, 0, 759, 153, 1, 0, 0, 0, 760, 761, 7, 7, 0, 0, 761, 155, 1, 0, 0, 0, 762, 763, 7, 8, 0, 0, 763, 764, 5, 114, 0, 0, 764, 765, 3, 158, 79, 0, 765, 766, 3, 160, 80, 0, 766, 157, 1, 0, 0, 0, 767, 768, 3, 28, 14, 0, 768, 159, 1, 0, 0, 0, 769, 770, 5, 74, 0, 0, 770, 775, 3, 162, 81, 0, 771, 772, 5, 62, 0, 0, 772, 774, 3, 162, 81, 0, 773, 771, 1, 0, 0, 0, 774, 777, 1, 0, 0, 0, 775, 773, 1, 0, 0, 0, 775, 776, 1, 0, 0, 0, 776, 161, 1, 0, 0, 0, 777, 775, 1, 0, 0, 0, 778, 779, 3, 128, 64, 0, 779, 163, 1, 0, 0, 0, 71, 175, 184, 215, 230, 236, 245, 251, 264, 268, 273, 279, 281, 295, 303, 307, 314, 320, 327, 335, 343, 351, 355, 359, 364, 375, 380, 384, 398, 409, 415, 429, 450, 458, 461, 466, 479, 485, 492, 503, 517, 529, 539, 545, 561, 570, 578, 583, 591, 593, 598, 605, 610, 615, 625, 631, 639, 641, 652, 659, 670, 675, 677, 689, 713, 724, 735, 740, 746, 749, 754, 775] \ No newline at end of file +[4, 1, 139, 781, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 2, 66, 7, 66, 2, 67, 7, 67, 2, 68, 7, 68, 2, 69, 7, 69, 2, 70, 7, 70, 2, 71, 7, 71, 2, 72, 7, 72, 2, 73, 7, 73, 2, 74, 7, 74, 2, 75, 7, 75, 2, 76, 7, 76, 2, 77, 7, 77, 2, 78, 7, 78, 2, 79, 7, 79, 2, 80, 7, 80, 2, 81, 7, 81, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 174, 8, 1, 10, 1, 12, 1, 177, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 185, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 216, 8, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 5, 7, 229, 8, 7, 10, 7, 12, 7, 232, 9, 7, 1, 8, 1, 8, 1, 8, 3, 8, 237, 8, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 5, 9, 244, 8, 9, 10, 9, 12, 9, 247, 9, 9, 1, 10, 1, 10, 1, 10, 3, 10, 252, 8, 10, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 5, 13, 263, 8, 13, 10, 13, 12, 13, 266, 9, 13, 1, 13, 3, 13, 269, 8, 13, 1, 14, 1, 14, 1, 14, 3, 14, 274, 8, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 280, 8, 14, 3, 14, 282, 8, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 5, 18, 294, 8, 18, 10, 18, 12, 18, 297, 9, 18, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 3, 20, 304, 8, 20, 1, 20, 1, 20, 3, 20, 308, 8, 20, 1, 21, 1, 21, 1, 21, 5, 21, 313, 8, 21, 10, 21, 12, 21, 316, 9, 21, 1, 22, 1, 22, 1, 22, 3, 22, 321, 8, 22, 1, 23, 1, 23, 1, 23, 5, 23, 326, 8, 23, 10, 23, 12, 23, 329, 9, 23, 1, 24, 1, 24, 1, 24, 5, 24, 334, 8, 24, 10, 24, 12, 24, 337, 9, 24, 1, 25, 1, 25, 1, 25, 5, 25, 342, 8, 25, 10, 25, 12, 25, 345, 9, 25, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 3, 27, 352, 8, 27, 1, 28, 1, 28, 3, 28, 356, 8, 28, 1, 29, 1, 29, 3, 29, 360, 8, 29, 1, 30, 1, 30, 1, 30, 3, 30, 365, 8, 30, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 5, 32, 374, 8, 32, 10, 32, 12, 32, 377, 9, 32, 1, 33, 1, 33, 3, 33, 381, 8, 33, 1, 33, 1, 33, 3, 33, 385, 8, 33, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 397, 8, 36, 10, 36, 12, 36, 400, 9, 36, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 3, 37, 410, 8, 37, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 416, 8, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 5, 41, 428, 8, 41, 10, 41, 12, 41, 431, 9, 41, 1, 42, 1, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 44, 1, 44, 1, 44, 1, 44, 1, 45, 1, 45, 1, 45, 1, 46, 1, 46, 1, 46, 1, 46, 3, 46, 451, 8, 46, 1, 46, 1, 46, 1, 46, 1, 46, 5, 46, 457, 8, 46, 10, 46, 12, 46, 460, 9, 46, 3, 46, 462, 8, 46, 1, 47, 1, 47, 1, 47, 3, 47, 467, 8, 47, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 1, 49, 1, 49, 3, 49, 480, 8, 49, 1, 50, 1, 50, 1, 50, 1, 50, 3, 50, 486, 8, 50, 1, 50, 1, 50, 1, 50, 1, 50, 1, 50, 3, 50, 493, 8, 50, 1, 51, 1, 51, 1, 51, 1, 52, 1, 52, 1, 52, 1, 53, 4, 53, 502, 8, 53, 11, 53, 12, 53, 503, 1, 54, 1, 54, 1, 54, 1, 54, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 5, 55, 516, 8, 55, 10, 55, 12, 55, 519, 9, 55, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 3, 56, 530, 8, 56, 1, 57, 1, 57, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 3, 58, 540, 8, 58, 1, 59, 1, 59, 1, 59, 1, 59, 3, 59, 546, 8, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 60, 1, 60, 1, 60, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 3, 61, 562, 8, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 5, 61, 569, 8, 61, 10, 61, 12, 61, 572, 9, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 3, 61, 579, 8, 61, 1, 61, 1, 61, 1, 61, 3, 61, 584, 8, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 5, 61, 592, 8, 61, 10, 61, 12, 61, 595, 9, 61, 1, 62, 1, 62, 3, 62, 599, 8, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 3, 62, 606, 8, 62, 1, 62, 1, 62, 1, 62, 3, 62, 611, 8, 62, 1, 63, 1, 63, 1, 63, 3, 63, 616, 8, 63, 1, 63, 1, 63, 1, 63, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 3, 64, 626, 8, 64, 1, 65, 1, 65, 1, 65, 1, 65, 3, 65, 632, 8, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 5, 65, 640, 8, 65, 10, 65, 12, 65, 643, 9, 65, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 3, 66, 653, 8, 66, 1, 66, 1, 66, 1, 66, 5, 66, 658, 8, 66, 10, 66, 12, 66, 661, 9, 66, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 5, 67, 669, 8, 67, 10, 67, 12, 67, 672, 9, 67, 1, 67, 1, 67, 3, 67, 676, 8, 67, 3, 67, 678, 8, 67, 1, 67, 1, 67, 1, 68, 1, 68, 1, 69, 1, 69, 1, 69, 1, 69, 5, 69, 688, 8, 69, 10, 69, 12, 69, 691, 9, 69, 1, 69, 1, 69, 1, 70, 1, 70, 1, 70, 1, 70, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 5, 71, 712, 8, 71, 10, 71, 12, 71, 715, 9, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 5, 71, 723, 8, 71, 10, 71, 12, 71, 726, 9, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 5, 71, 734, 8, 71, 10, 71, 12, 71, 737, 9, 71, 1, 71, 1, 71, 3, 71, 741, 8, 71, 1, 72, 1, 72, 1, 73, 1, 73, 3, 73, 747, 8, 73, 1, 74, 3, 74, 750, 8, 74, 1, 74, 1, 74, 1, 75, 3, 75, 755, 8, 75, 1, 75, 1, 75, 1, 76, 1, 76, 1, 77, 1, 77, 1, 78, 1, 78, 1, 78, 1, 78, 1, 78, 1, 79, 1, 79, 1, 80, 1, 80, 1, 80, 1, 80, 5, 80, 774, 8, 80, 10, 80, 12, 80, 777, 9, 80, 1, 81, 1, 81, 1, 81, 0, 5, 2, 110, 122, 130, 132, 82, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 0, 9, 2, 0, 53, 53, 107, 107, 1, 0, 101, 102, 2, 0, 57, 57, 63, 63, 2, 0, 66, 66, 69, 69, 1, 0, 87, 88, 1, 0, 89, 91, 2, 0, 65, 65, 78, 78, 2, 0, 80, 80, 82, 86, 2, 0, 22, 22, 24, 25, 816, 0, 164, 1, 0, 0, 0, 2, 167, 1, 0, 0, 0, 4, 184, 1, 0, 0, 0, 6, 215, 1, 0, 0, 0, 8, 217, 1, 0, 0, 0, 10, 220, 1, 0, 0, 0, 12, 222, 1, 0, 0, 0, 14, 225, 1, 0, 0, 0, 16, 236, 1, 0, 0, 0, 18, 240, 1, 0, 0, 0, 20, 248, 1, 0, 0, 0, 22, 253, 1, 0, 0, 0, 24, 256, 1, 0, 0, 0, 26, 259, 1, 0, 0, 0, 28, 281, 1, 0, 0, 0, 30, 283, 1, 0, 0, 0, 32, 285, 1, 0, 0, 0, 34, 287, 1, 0, 0, 0, 36, 289, 1, 0, 0, 0, 38, 298, 1, 0, 0, 0, 40, 301, 1, 0, 0, 0, 42, 309, 1, 0, 0, 0, 44, 317, 1, 0, 0, 0, 46, 322, 1, 0, 0, 0, 48, 330, 1, 0, 0, 0, 50, 338, 1, 0, 0, 0, 52, 346, 1, 0, 0, 0, 54, 351, 1, 0, 0, 0, 56, 355, 1, 0, 0, 0, 58, 359, 1, 0, 0, 0, 60, 364, 1, 0, 0, 0, 62, 366, 1, 0, 0, 0, 64, 369, 1, 0, 0, 0, 66, 378, 1, 0, 0, 0, 68, 386, 1, 0, 0, 0, 70, 389, 1, 0, 0, 0, 72, 392, 1, 0, 0, 0, 74, 409, 1, 0, 0, 0, 76, 411, 1, 0, 0, 0, 78, 417, 1, 0, 0, 0, 80, 421, 1, 0, 0, 0, 82, 424, 1, 0, 0, 0, 84, 432, 1, 0, 0, 0, 86, 436, 1, 0, 0, 0, 88, 439, 1, 0, 0, 0, 90, 443, 1, 0, 0, 0, 92, 446, 1, 0, 0, 0, 94, 466, 1, 0, 0, 0, 96, 470, 1, 0, 0, 0, 98, 475, 1, 0, 0, 0, 100, 481, 1, 0, 0, 0, 102, 494, 1, 0, 0, 0, 104, 497, 1, 0, 0, 0, 106, 501, 1, 0, 0, 0, 108, 505, 1, 0, 0, 0, 110, 509, 1, 0, 0, 0, 112, 529, 1, 0, 0, 0, 114, 531, 1, 0, 0, 0, 116, 533, 1, 0, 0, 0, 118, 541, 1, 0, 0, 0, 120, 551, 1, 0, 0, 0, 122, 583, 1, 0, 0, 0, 124, 610, 1, 0, 0, 0, 126, 612, 1, 0, 0, 0, 128, 625, 1, 0, 0, 0, 130, 631, 1, 0, 0, 0, 132, 652, 1, 0, 0, 0, 134, 662, 1, 0, 0, 0, 136, 681, 1, 0, 0, 0, 138, 683, 1, 0, 0, 0, 140, 694, 1, 0, 0, 0, 142, 740, 1, 0, 0, 0, 144, 742, 1, 0, 0, 0, 146, 746, 1, 0, 0, 0, 148, 749, 1, 0, 0, 0, 150, 754, 1, 0, 0, 0, 152, 758, 1, 0, 0, 0, 154, 760, 1, 0, 0, 0, 156, 762, 1, 0, 0, 0, 158, 767, 1, 0, 0, 0, 160, 769, 1, 0, 0, 0, 162, 778, 1, 0, 0, 0, 164, 165, 3, 2, 1, 0, 165, 166, 5, 0, 0, 1, 166, 1, 1, 0, 0, 0, 167, 168, 6, 1, -1, 0, 168, 169, 3, 4, 2, 0, 169, 175, 1, 0, 0, 0, 170, 171, 10, 1, 0, 0, 171, 172, 5, 52, 0, 0, 172, 174, 3, 6, 3, 0, 173, 170, 1, 0, 0, 0, 174, 177, 1, 0, 0, 0, 175, 173, 1, 0, 0, 0, 175, 176, 1, 0, 0, 0, 176, 3, 1, 0, 0, 0, 177, 175, 1, 0, 0, 0, 178, 185, 3, 86, 43, 0, 179, 185, 3, 22, 11, 0, 180, 185, 3, 12, 6, 0, 181, 185, 3, 90, 45, 0, 182, 183, 4, 2, 1, 0, 183, 185, 3, 24, 12, 0, 184, 178, 1, 0, 0, 0, 184, 179, 1, 0, 0, 0, 184, 180, 1, 0, 0, 0, 184, 181, 1, 0, 0, 0, 184, 182, 1, 0, 0, 0, 185, 5, 1, 0, 0, 0, 186, 216, 3, 38, 19, 0, 187, 216, 3, 8, 4, 0, 188, 216, 3, 68, 34, 0, 189, 216, 3, 62, 31, 0, 190, 216, 3, 40, 20, 0, 191, 216, 3, 64, 32, 0, 192, 216, 3, 70, 35, 0, 193, 216, 3, 72, 36, 0, 194, 216, 3, 76, 38, 0, 195, 216, 3, 78, 39, 0, 196, 216, 3, 92, 46, 0, 197, 216, 3, 80, 40, 0, 198, 216, 3, 156, 78, 0, 199, 216, 3, 100, 50, 0, 200, 216, 3, 118, 59, 0, 201, 202, 4, 3, 2, 0, 202, 216, 3, 98, 49, 0, 203, 204, 4, 3, 3, 0, 204, 216, 3, 96, 48, 0, 205, 206, 4, 3, 4, 0, 206, 216, 3, 102, 51, 0, 207, 208, 4, 3, 5, 0, 208, 216, 3, 104, 52, 0, 209, 210, 4, 3, 6, 0, 210, 216, 3, 116, 58, 0, 211, 212, 4, 3, 7, 0, 212, 216, 3, 114, 57, 0, 213, 214, 4, 3, 8, 0, 214, 216, 3, 120, 60, 0, 215, 186, 1, 0, 0, 0, 215, 187, 1, 0, 0, 0, 215, 188, 1, 0, 0, 0, 215, 189, 1, 0, 0, 0, 215, 190, 1, 0, 0, 0, 215, 191, 1, 0, 0, 0, 215, 192, 1, 0, 0, 0, 215, 193, 1, 0, 0, 0, 215, 194, 1, 0, 0, 0, 215, 195, 1, 0, 0, 0, 215, 196, 1, 0, 0, 0, 215, 197, 1, 0, 0, 0, 215, 198, 1, 0, 0, 0, 215, 199, 1, 0, 0, 0, 215, 200, 1, 0, 0, 0, 215, 201, 1, 0, 0, 0, 215, 203, 1, 0, 0, 0, 215, 205, 1, 0, 0, 0, 215, 207, 1, 0, 0, 0, 215, 209, 1, 0, 0, 0, 215, 211, 1, 0, 0, 0, 215, 213, 1, 0, 0, 0, 216, 7, 1, 0, 0, 0, 217, 218, 5, 15, 0, 0, 218, 219, 3, 122, 61, 0, 219, 9, 1, 0, 0, 0, 220, 221, 3, 52, 26, 0, 221, 11, 1, 0, 0, 0, 222, 223, 5, 12, 0, 0, 223, 224, 3, 14, 7, 0, 224, 13, 1, 0, 0, 0, 225, 230, 3, 16, 8, 0, 226, 227, 5, 62, 0, 0, 227, 229, 3, 16, 8, 0, 228, 226, 1, 0, 0, 0, 229, 232, 1, 0, 0, 0, 230, 228, 1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 15, 1, 0, 0, 0, 232, 230, 1, 0, 0, 0, 233, 234, 3, 46, 23, 0, 234, 235, 5, 58, 0, 0, 235, 237, 1, 0, 0, 0, 236, 233, 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 238, 1, 0, 0, 0, 238, 239, 3, 122, 61, 0, 239, 17, 1, 0, 0, 0, 240, 245, 3, 20, 10, 0, 241, 242, 5, 62, 0, 0, 242, 244, 3, 20, 10, 0, 243, 241, 1, 0, 0, 0, 244, 247, 1, 0, 0, 0, 245, 243, 1, 0, 0, 0, 245, 246, 1, 0, 0, 0, 246, 19, 1, 0, 0, 0, 247, 245, 1, 0, 0, 0, 248, 251, 3, 46, 23, 0, 249, 250, 5, 58, 0, 0, 250, 252, 3, 122, 61, 0, 251, 249, 1, 0, 0, 0, 251, 252, 1, 0, 0, 0, 252, 21, 1, 0, 0, 0, 253, 254, 5, 19, 0, 0, 254, 255, 3, 26, 13, 0, 255, 23, 1, 0, 0, 0, 256, 257, 5, 20, 0, 0, 257, 258, 3, 26, 13, 0, 258, 25, 1, 0, 0, 0, 259, 264, 3, 28, 14, 0, 260, 261, 5, 62, 0, 0, 261, 263, 3, 28, 14, 0, 262, 260, 1, 0, 0, 0, 263, 266, 1, 0, 0, 0, 264, 262, 1, 0, 0, 0, 264, 265, 1, 0, 0, 0, 265, 268, 1, 0, 0, 0, 266, 264, 1, 0, 0, 0, 267, 269, 3, 36, 18, 0, 268, 267, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, 27, 1, 0, 0, 0, 270, 271, 3, 30, 15, 0, 271, 272, 5, 61, 0, 0, 272, 274, 1, 0, 0, 0, 273, 270, 1, 0, 0, 0, 273, 274, 1, 0, 0, 0, 274, 275, 1, 0, 0, 0, 275, 282, 3, 34, 17, 0, 276, 279, 3, 34, 17, 0, 277, 278, 5, 60, 0, 0, 278, 280, 3, 32, 16, 0, 279, 277, 1, 0, 0, 0, 279, 280, 1, 0, 0, 0, 280, 282, 1, 0, 0, 0, 281, 273, 1, 0, 0, 0, 281, 276, 1, 0, 0, 0, 282, 29, 1, 0, 0, 0, 283, 284, 7, 0, 0, 0, 284, 31, 1, 0, 0, 0, 285, 286, 7, 0, 0, 0, 286, 33, 1, 0, 0, 0, 287, 288, 7, 0, 0, 0, 288, 35, 1, 0, 0, 0, 289, 290, 5, 106, 0, 0, 290, 295, 5, 107, 0, 0, 291, 292, 5, 62, 0, 0, 292, 294, 5, 107, 0, 0, 293, 291, 1, 0, 0, 0, 294, 297, 1, 0, 0, 0, 295, 293, 1, 0, 0, 0, 295, 296, 1, 0, 0, 0, 296, 37, 1, 0, 0, 0, 297, 295, 1, 0, 0, 0, 298, 299, 5, 9, 0, 0, 299, 300, 3, 14, 7, 0, 300, 39, 1, 0, 0, 0, 301, 303, 5, 14, 0, 0, 302, 304, 3, 42, 21, 0, 303, 302, 1, 0, 0, 0, 303, 304, 1, 0, 0, 0, 304, 307, 1, 0, 0, 0, 305, 306, 5, 59, 0, 0, 306, 308, 3, 14, 7, 0, 307, 305, 1, 0, 0, 0, 307, 308, 1, 0, 0, 0, 308, 41, 1, 0, 0, 0, 309, 314, 3, 44, 22, 0, 310, 311, 5, 62, 0, 0, 311, 313, 3, 44, 22, 0, 312, 310, 1, 0, 0, 0, 313, 316, 1, 0, 0, 0, 314, 312, 1, 0, 0, 0, 314, 315, 1, 0, 0, 0, 315, 43, 1, 0, 0, 0, 316, 314, 1, 0, 0, 0, 317, 320, 3, 16, 8, 0, 318, 319, 5, 15, 0, 0, 319, 321, 3, 122, 61, 0, 320, 318, 1, 0, 0, 0, 320, 321, 1, 0, 0, 0, 321, 45, 1, 0, 0, 0, 322, 327, 3, 60, 30, 0, 323, 324, 5, 64, 0, 0, 324, 326, 3, 60, 30, 0, 325, 323, 1, 0, 0, 0, 326, 329, 1, 0, 0, 0, 327, 325, 1, 0, 0, 0, 327, 328, 1, 0, 0, 0, 328, 47, 1, 0, 0, 0, 329, 327, 1, 0, 0, 0, 330, 335, 3, 54, 27, 0, 331, 332, 5, 64, 0, 0, 332, 334, 3, 54, 27, 0, 333, 331, 1, 0, 0, 0, 334, 337, 1, 0, 0, 0, 335, 333, 1, 0, 0, 0, 335, 336, 1, 0, 0, 0, 336, 49, 1, 0, 0, 0, 337, 335, 1, 0, 0, 0, 338, 343, 3, 48, 24, 0, 339, 340, 5, 62, 0, 0, 340, 342, 3, 48, 24, 0, 341, 339, 1, 0, 0, 0, 342, 345, 1, 0, 0, 0, 343, 341, 1, 0, 0, 0, 343, 344, 1, 0, 0, 0, 344, 51, 1, 0, 0, 0, 345, 343, 1, 0, 0, 0, 346, 347, 7, 1, 0, 0, 347, 53, 1, 0, 0, 0, 348, 352, 5, 128, 0, 0, 349, 352, 3, 56, 28, 0, 350, 352, 3, 58, 29, 0, 351, 348, 1, 0, 0, 0, 351, 349, 1, 0, 0, 0, 351, 350, 1, 0, 0, 0, 352, 55, 1, 0, 0, 0, 353, 356, 5, 76, 0, 0, 354, 356, 5, 95, 0, 0, 355, 353, 1, 0, 0, 0, 355, 354, 1, 0, 0, 0, 356, 57, 1, 0, 0, 0, 357, 360, 5, 94, 0, 0, 358, 360, 5, 96, 0, 0, 359, 357, 1, 0, 0, 0, 359, 358, 1, 0, 0, 0, 360, 59, 1, 0, 0, 0, 361, 365, 3, 52, 26, 0, 362, 365, 3, 56, 28, 0, 363, 365, 3, 58, 29, 0, 364, 361, 1, 0, 0, 0, 364, 362, 1, 0, 0, 0, 364, 363, 1, 0, 0, 0, 365, 61, 1, 0, 0, 0, 366, 367, 5, 11, 0, 0, 367, 368, 3, 142, 71, 0, 368, 63, 1, 0, 0, 0, 369, 370, 5, 13, 0, 0, 370, 375, 3, 66, 33, 0, 371, 372, 5, 62, 0, 0, 372, 374, 3, 66, 33, 0, 373, 371, 1, 0, 0, 0, 374, 377, 1, 0, 0, 0, 375, 373, 1, 0, 0, 0, 375, 376, 1, 0, 0, 0, 376, 65, 1, 0, 0, 0, 377, 375, 1, 0, 0, 0, 378, 380, 3, 122, 61, 0, 379, 381, 7, 2, 0, 0, 380, 379, 1, 0, 0, 0, 380, 381, 1, 0, 0, 0, 381, 384, 1, 0, 0, 0, 382, 383, 5, 73, 0, 0, 383, 385, 7, 3, 0, 0, 384, 382, 1, 0, 0, 0, 384, 385, 1, 0, 0, 0, 385, 67, 1, 0, 0, 0, 386, 387, 5, 29, 0, 0, 387, 388, 3, 50, 25, 0, 388, 69, 1, 0, 0, 0, 389, 390, 5, 28, 0, 0, 390, 391, 3, 50, 25, 0, 391, 71, 1, 0, 0, 0, 392, 393, 5, 32, 0, 0, 393, 398, 3, 74, 37, 0, 394, 395, 5, 62, 0, 0, 395, 397, 3, 74, 37, 0, 396, 394, 1, 0, 0, 0, 397, 400, 1, 0, 0, 0, 398, 396, 1, 0, 0, 0, 398, 399, 1, 0, 0, 0, 399, 73, 1, 0, 0, 0, 400, 398, 1, 0, 0, 0, 401, 402, 3, 48, 24, 0, 402, 403, 5, 132, 0, 0, 403, 404, 3, 48, 24, 0, 404, 410, 1, 0, 0, 0, 405, 406, 3, 48, 24, 0, 406, 407, 5, 58, 0, 0, 407, 408, 3, 48, 24, 0, 408, 410, 1, 0, 0, 0, 409, 401, 1, 0, 0, 0, 409, 405, 1, 0, 0, 0, 410, 75, 1, 0, 0, 0, 411, 412, 5, 8, 0, 0, 412, 413, 3, 132, 66, 0, 413, 415, 3, 152, 76, 0, 414, 416, 3, 82, 41, 0, 415, 414, 1, 0, 0, 0, 415, 416, 1, 0, 0, 0, 416, 77, 1, 0, 0, 0, 417, 418, 5, 10, 0, 0, 418, 419, 3, 132, 66, 0, 419, 420, 3, 152, 76, 0, 420, 79, 1, 0, 0, 0, 421, 422, 5, 27, 0, 0, 422, 423, 3, 46, 23, 0, 423, 81, 1, 0, 0, 0, 424, 429, 3, 84, 42, 0, 425, 426, 5, 62, 0, 0, 426, 428, 3, 84, 42, 0, 427, 425, 1, 0, 0, 0, 428, 431, 1, 0, 0, 0, 429, 427, 1, 0, 0, 0, 429, 430, 1, 0, 0, 0, 430, 83, 1, 0, 0, 0, 431, 429, 1, 0, 0, 0, 432, 433, 3, 52, 26, 0, 433, 434, 5, 58, 0, 0, 434, 435, 3, 132, 66, 0, 435, 85, 1, 0, 0, 0, 436, 437, 5, 6, 0, 0, 437, 438, 3, 88, 44, 0, 438, 87, 1, 0, 0, 0, 439, 440, 5, 97, 0, 0, 440, 441, 3, 2, 1, 0, 441, 442, 5, 98, 0, 0, 442, 89, 1, 0, 0, 0, 443, 444, 5, 33, 0, 0, 444, 445, 5, 136, 0, 0, 445, 91, 1, 0, 0, 0, 446, 447, 5, 5, 0, 0, 447, 450, 5, 38, 0, 0, 448, 449, 5, 74, 0, 0, 449, 451, 3, 48, 24, 0, 450, 448, 1, 0, 0, 0, 450, 451, 1, 0, 0, 0, 451, 461, 1, 0, 0, 0, 452, 453, 5, 79, 0, 0, 453, 458, 3, 94, 47, 0, 454, 455, 5, 62, 0, 0, 455, 457, 3, 94, 47, 0, 456, 454, 1, 0, 0, 0, 457, 460, 1, 0, 0, 0, 458, 456, 1, 0, 0, 0, 458, 459, 1, 0, 0, 0, 459, 462, 1, 0, 0, 0, 460, 458, 1, 0, 0, 0, 461, 452, 1, 0, 0, 0, 461, 462, 1, 0, 0, 0, 462, 93, 1, 0, 0, 0, 463, 464, 3, 48, 24, 0, 464, 465, 5, 58, 0, 0, 465, 467, 1, 0, 0, 0, 466, 463, 1, 0, 0, 0, 466, 467, 1, 0, 0, 0, 467, 468, 1, 0, 0, 0, 468, 469, 3, 48, 24, 0, 469, 95, 1, 0, 0, 0, 470, 471, 5, 26, 0, 0, 471, 472, 3, 28, 14, 0, 472, 473, 5, 74, 0, 0, 473, 474, 3, 50, 25, 0, 474, 97, 1, 0, 0, 0, 475, 476, 5, 16, 0, 0, 476, 479, 3, 42, 21, 0, 477, 478, 5, 59, 0, 0, 478, 480, 3, 14, 7, 0, 479, 477, 1, 0, 0, 0, 479, 480, 1, 0, 0, 0, 480, 99, 1, 0, 0, 0, 481, 482, 5, 4, 0, 0, 482, 485, 3, 46, 23, 0, 483, 484, 5, 74, 0, 0, 484, 486, 3, 46, 23, 0, 485, 483, 1, 0, 0, 0, 485, 486, 1, 0, 0, 0, 486, 492, 1, 0, 0, 0, 487, 488, 5, 132, 0, 0, 488, 489, 3, 46, 23, 0, 489, 490, 5, 62, 0, 0, 490, 491, 3, 46, 23, 0, 491, 493, 1, 0, 0, 0, 492, 487, 1, 0, 0, 0, 492, 493, 1, 0, 0, 0, 493, 101, 1, 0, 0, 0, 494, 495, 5, 30, 0, 0, 495, 496, 3, 50, 25, 0, 496, 103, 1, 0, 0, 0, 497, 498, 5, 21, 0, 0, 498, 499, 3, 106, 53, 0, 499, 105, 1, 0, 0, 0, 500, 502, 3, 108, 54, 0, 501, 500, 1, 0, 0, 0, 502, 503, 1, 0, 0, 0, 503, 501, 1, 0, 0, 0, 503, 504, 1, 0, 0, 0, 504, 107, 1, 0, 0, 0, 505, 506, 5, 99, 0, 0, 506, 507, 3, 110, 55, 0, 507, 508, 5, 100, 0, 0, 508, 109, 1, 0, 0, 0, 509, 510, 6, 55, -1, 0, 510, 511, 3, 112, 56, 0, 511, 517, 1, 0, 0, 0, 512, 513, 10, 1, 0, 0, 513, 514, 5, 52, 0, 0, 514, 516, 3, 112, 56, 0, 515, 512, 1, 0, 0, 0, 516, 519, 1, 0, 0, 0, 517, 515, 1, 0, 0, 0, 517, 518, 1, 0, 0, 0, 518, 111, 1, 0, 0, 0, 519, 517, 1, 0, 0, 0, 520, 530, 3, 38, 19, 0, 521, 530, 3, 8, 4, 0, 522, 530, 3, 62, 31, 0, 523, 530, 3, 40, 20, 0, 524, 530, 3, 64, 32, 0, 525, 530, 3, 76, 38, 0, 526, 530, 3, 100, 50, 0, 527, 530, 3, 118, 59, 0, 528, 530, 3, 78, 39, 0, 529, 520, 1, 0, 0, 0, 529, 521, 1, 0, 0, 0, 529, 522, 1, 0, 0, 0, 529, 523, 1, 0, 0, 0, 529, 524, 1, 0, 0, 0, 529, 525, 1, 0, 0, 0, 529, 526, 1, 0, 0, 0, 529, 527, 1, 0, 0, 0, 529, 528, 1, 0, 0, 0, 530, 113, 1, 0, 0, 0, 531, 532, 5, 31, 0, 0, 532, 115, 1, 0, 0, 0, 533, 534, 5, 17, 0, 0, 534, 535, 3, 142, 71, 0, 535, 536, 5, 74, 0, 0, 536, 539, 3, 18, 9, 0, 537, 538, 5, 79, 0, 0, 538, 540, 3, 82, 41, 0, 539, 537, 1, 0, 0, 0, 539, 540, 1, 0, 0, 0, 540, 117, 1, 0, 0, 0, 541, 545, 5, 7, 0, 0, 542, 543, 3, 46, 23, 0, 543, 544, 5, 58, 0, 0, 544, 546, 1, 0, 0, 0, 545, 542, 1, 0, 0, 0, 545, 546, 1, 0, 0, 0, 546, 547, 1, 0, 0, 0, 547, 548, 3, 132, 66, 0, 548, 549, 5, 79, 0, 0, 549, 550, 3, 60, 30, 0, 550, 119, 1, 0, 0, 0, 551, 552, 5, 18, 0, 0, 552, 553, 3, 148, 74, 0, 553, 121, 1, 0, 0, 0, 554, 555, 6, 61, -1, 0, 555, 556, 5, 71, 0, 0, 556, 584, 3, 122, 61, 8, 557, 584, 3, 128, 64, 0, 558, 584, 3, 124, 62, 0, 559, 561, 3, 128, 64, 0, 560, 562, 5, 71, 0, 0, 561, 560, 1, 0, 0, 0, 561, 562, 1, 0, 0, 0, 562, 563, 1, 0, 0, 0, 563, 564, 5, 67, 0, 0, 564, 565, 5, 99, 0, 0, 565, 570, 3, 128, 64, 0, 566, 567, 5, 62, 0, 0, 567, 569, 3, 128, 64, 0, 568, 566, 1, 0, 0, 0, 569, 572, 1, 0, 0, 0, 570, 568, 1, 0, 0, 0, 570, 571, 1, 0, 0, 0, 571, 573, 1, 0, 0, 0, 572, 570, 1, 0, 0, 0, 573, 574, 5, 100, 0, 0, 574, 584, 1, 0, 0, 0, 575, 576, 3, 128, 64, 0, 576, 578, 5, 68, 0, 0, 577, 579, 5, 71, 0, 0, 578, 577, 1, 0, 0, 0, 578, 579, 1, 0, 0, 0, 579, 580, 1, 0, 0, 0, 580, 581, 5, 72, 0, 0, 581, 584, 1, 0, 0, 0, 582, 584, 3, 126, 63, 0, 583, 554, 1, 0, 0, 0, 583, 557, 1, 0, 0, 0, 583, 558, 1, 0, 0, 0, 583, 559, 1, 0, 0, 0, 583, 575, 1, 0, 0, 0, 583, 582, 1, 0, 0, 0, 584, 593, 1, 0, 0, 0, 585, 586, 10, 5, 0, 0, 586, 587, 5, 56, 0, 0, 587, 592, 3, 122, 61, 6, 588, 589, 10, 4, 0, 0, 589, 590, 5, 75, 0, 0, 590, 592, 3, 122, 61, 5, 591, 585, 1, 0, 0, 0, 591, 588, 1, 0, 0, 0, 592, 595, 1, 0, 0, 0, 593, 591, 1, 0, 0, 0, 593, 594, 1, 0, 0, 0, 594, 123, 1, 0, 0, 0, 595, 593, 1, 0, 0, 0, 596, 598, 3, 128, 64, 0, 597, 599, 5, 71, 0, 0, 598, 597, 1, 0, 0, 0, 598, 599, 1, 0, 0, 0, 599, 600, 1, 0, 0, 0, 600, 601, 5, 70, 0, 0, 601, 602, 3, 152, 76, 0, 602, 611, 1, 0, 0, 0, 603, 605, 3, 128, 64, 0, 604, 606, 5, 71, 0, 0, 605, 604, 1, 0, 0, 0, 605, 606, 1, 0, 0, 0, 606, 607, 1, 0, 0, 0, 607, 608, 5, 77, 0, 0, 608, 609, 3, 152, 76, 0, 609, 611, 1, 0, 0, 0, 610, 596, 1, 0, 0, 0, 610, 603, 1, 0, 0, 0, 611, 125, 1, 0, 0, 0, 612, 615, 3, 46, 23, 0, 613, 614, 5, 60, 0, 0, 614, 616, 3, 10, 5, 0, 615, 613, 1, 0, 0, 0, 615, 616, 1, 0, 0, 0, 616, 617, 1, 0, 0, 0, 617, 618, 5, 61, 0, 0, 618, 619, 3, 142, 71, 0, 619, 127, 1, 0, 0, 0, 620, 626, 3, 130, 65, 0, 621, 622, 3, 130, 65, 0, 622, 623, 3, 154, 77, 0, 623, 624, 3, 130, 65, 0, 624, 626, 1, 0, 0, 0, 625, 620, 1, 0, 0, 0, 625, 621, 1, 0, 0, 0, 626, 129, 1, 0, 0, 0, 627, 628, 6, 65, -1, 0, 628, 632, 3, 132, 66, 0, 629, 630, 7, 4, 0, 0, 630, 632, 3, 130, 65, 3, 631, 627, 1, 0, 0, 0, 631, 629, 1, 0, 0, 0, 632, 641, 1, 0, 0, 0, 633, 634, 10, 2, 0, 0, 634, 635, 7, 5, 0, 0, 635, 640, 3, 130, 65, 3, 636, 637, 10, 1, 0, 0, 637, 638, 7, 4, 0, 0, 638, 640, 3, 130, 65, 2, 639, 633, 1, 0, 0, 0, 639, 636, 1, 0, 0, 0, 640, 643, 1, 0, 0, 0, 641, 639, 1, 0, 0, 0, 641, 642, 1, 0, 0, 0, 642, 131, 1, 0, 0, 0, 643, 641, 1, 0, 0, 0, 644, 645, 6, 66, -1, 0, 645, 653, 3, 142, 71, 0, 646, 653, 3, 46, 23, 0, 647, 653, 3, 134, 67, 0, 648, 649, 5, 99, 0, 0, 649, 650, 3, 122, 61, 0, 650, 651, 5, 100, 0, 0, 651, 653, 1, 0, 0, 0, 652, 644, 1, 0, 0, 0, 652, 646, 1, 0, 0, 0, 652, 647, 1, 0, 0, 0, 652, 648, 1, 0, 0, 0, 653, 659, 1, 0, 0, 0, 654, 655, 10, 1, 0, 0, 655, 656, 5, 60, 0, 0, 656, 658, 3, 10, 5, 0, 657, 654, 1, 0, 0, 0, 658, 661, 1, 0, 0, 0, 659, 657, 1, 0, 0, 0, 659, 660, 1, 0, 0, 0, 660, 133, 1, 0, 0, 0, 661, 659, 1, 0, 0, 0, 662, 663, 3, 136, 68, 0, 663, 677, 5, 99, 0, 0, 664, 678, 5, 89, 0, 0, 665, 670, 3, 122, 61, 0, 666, 667, 5, 62, 0, 0, 667, 669, 3, 122, 61, 0, 668, 666, 1, 0, 0, 0, 669, 672, 1, 0, 0, 0, 670, 668, 1, 0, 0, 0, 670, 671, 1, 0, 0, 0, 671, 675, 1, 0, 0, 0, 672, 670, 1, 0, 0, 0, 673, 674, 5, 62, 0, 0, 674, 676, 3, 138, 69, 0, 675, 673, 1, 0, 0, 0, 675, 676, 1, 0, 0, 0, 676, 678, 1, 0, 0, 0, 677, 664, 1, 0, 0, 0, 677, 665, 1, 0, 0, 0, 677, 678, 1, 0, 0, 0, 678, 679, 1, 0, 0, 0, 679, 680, 5, 100, 0, 0, 680, 135, 1, 0, 0, 0, 681, 682, 3, 60, 30, 0, 682, 137, 1, 0, 0, 0, 683, 684, 5, 92, 0, 0, 684, 689, 3, 140, 70, 0, 685, 686, 5, 62, 0, 0, 686, 688, 3, 140, 70, 0, 687, 685, 1, 0, 0, 0, 688, 691, 1, 0, 0, 0, 689, 687, 1, 0, 0, 0, 689, 690, 1, 0, 0, 0, 690, 692, 1, 0, 0, 0, 691, 689, 1, 0, 0, 0, 692, 693, 5, 93, 0, 0, 693, 139, 1, 0, 0, 0, 694, 695, 3, 152, 76, 0, 695, 696, 5, 61, 0, 0, 696, 697, 3, 142, 71, 0, 697, 141, 1, 0, 0, 0, 698, 741, 5, 72, 0, 0, 699, 700, 3, 150, 75, 0, 700, 701, 5, 101, 0, 0, 701, 741, 1, 0, 0, 0, 702, 741, 3, 148, 74, 0, 703, 741, 3, 150, 75, 0, 704, 741, 3, 144, 72, 0, 705, 741, 3, 56, 28, 0, 706, 741, 3, 152, 76, 0, 707, 708, 5, 97, 0, 0, 708, 713, 3, 146, 73, 0, 709, 710, 5, 62, 0, 0, 710, 712, 3, 146, 73, 0, 711, 709, 1, 0, 0, 0, 712, 715, 1, 0, 0, 0, 713, 711, 1, 0, 0, 0, 713, 714, 1, 0, 0, 0, 714, 716, 1, 0, 0, 0, 715, 713, 1, 0, 0, 0, 716, 717, 5, 98, 0, 0, 717, 741, 1, 0, 0, 0, 718, 719, 5, 97, 0, 0, 719, 724, 3, 144, 72, 0, 720, 721, 5, 62, 0, 0, 721, 723, 3, 144, 72, 0, 722, 720, 1, 0, 0, 0, 723, 726, 1, 0, 0, 0, 724, 722, 1, 0, 0, 0, 724, 725, 1, 0, 0, 0, 725, 727, 1, 0, 0, 0, 726, 724, 1, 0, 0, 0, 727, 728, 5, 98, 0, 0, 728, 741, 1, 0, 0, 0, 729, 730, 5, 97, 0, 0, 730, 735, 3, 152, 76, 0, 731, 732, 5, 62, 0, 0, 732, 734, 3, 152, 76, 0, 733, 731, 1, 0, 0, 0, 734, 737, 1, 0, 0, 0, 735, 733, 1, 0, 0, 0, 735, 736, 1, 0, 0, 0, 736, 738, 1, 0, 0, 0, 737, 735, 1, 0, 0, 0, 738, 739, 5, 98, 0, 0, 739, 741, 1, 0, 0, 0, 740, 698, 1, 0, 0, 0, 740, 699, 1, 0, 0, 0, 740, 702, 1, 0, 0, 0, 740, 703, 1, 0, 0, 0, 740, 704, 1, 0, 0, 0, 740, 705, 1, 0, 0, 0, 740, 706, 1, 0, 0, 0, 740, 707, 1, 0, 0, 0, 740, 718, 1, 0, 0, 0, 740, 729, 1, 0, 0, 0, 741, 143, 1, 0, 0, 0, 742, 743, 7, 6, 0, 0, 743, 145, 1, 0, 0, 0, 744, 747, 3, 148, 74, 0, 745, 747, 3, 150, 75, 0, 746, 744, 1, 0, 0, 0, 746, 745, 1, 0, 0, 0, 747, 147, 1, 0, 0, 0, 748, 750, 7, 4, 0, 0, 749, 748, 1, 0, 0, 0, 749, 750, 1, 0, 0, 0, 750, 751, 1, 0, 0, 0, 751, 752, 5, 55, 0, 0, 752, 149, 1, 0, 0, 0, 753, 755, 7, 4, 0, 0, 754, 753, 1, 0, 0, 0, 754, 755, 1, 0, 0, 0, 755, 756, 1, 0, 0, 0, 756, 757, 5, 54, 0, 0, 757, 151, 1, 0, 0, 0, 758, 759, 5, 53, 0, 0, 759, 153, 1, 0, 0, 0, 760, 761, 7, 7, 0, 0, 761, 155, 1, 0, 0, 0, 762, 763, 7, 8, 0, 0, 763, 764, 5, 114, 0, 0, 764, 765, 3, 158, 79, 0, 765, 766, 3, 160, 80, 0, 766, 157, 1, 0, 0, 0, 767, 768, 3, 28, 14, 0, 768, 159, 1, 0, 0, 0, 769, 770, 5, 74, 0, 0, 770, 775, 3, 162, 81, 0, 771, 772, 5, 62, 0, 0, 772, 774, 3, 162, 81, 0, 773, 771, 1, 0, 0, 0, 774, 777, 1, 0, 0, 0, 775, 773, 1, 0, 0, 0, 775, 776, 1, 0, 0, 0, 776, 161, 1, 0, 0, 0, 777, 775, 1, 0, 0, 0, 778, 779, 3, 128, 64, 0, 779, 163, 1, 0, 0, 0, 71, 175, 184, 215, 230, 236, 245, 251, 264, 268, 273, 279, 281, 295, 303, 307, 314, 320, 327, 335, 343, 351, 355, 359, 364, 375, 380, 384, 398, 409, 415, 429, 450, 458, 461, 466, 479, 485, 492, 503, 517, 529, 539, 545, 561, 570, 578, 583, 591, 593, 598, 605, 610, 615, 625, 631, 639, 641, 652, 659, 670, 675, 677, 689, 713, 724, 735, 740, 746, 749, 754, 775] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.java index 0a0a113c6b394..603da1b0ba46a 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.java @@ -4370,7 +4370,6 @@ public final RrfCommandContext rrfCommand() throws RecognitionException { @SuppressWarnings("CheckReturnValue") public static class RerankCommandContext extends ParserRuleContext { public ConstantContext queryText; - public IdentifierOrParameterContext inferenceId; public TerminalNode DEV_RERANK() { return getToken(EsqlBaseParser.DEV_RERANK, 0); } public TerminalNode ON() { return getToken(EsqlBaseParser.ON, 0); } public RerankFieldsContext rerankFields() { @@ -4380,8 +4379,8 @@ public ConstantContext constant() { return getRuleContext(ConstantContext.class,0); } public TerminalNode WITH() { return getToken(EsqlBaseParser.WITH, 0); } - public IdentifierOrParameterContext identifierOrParameter() { - return getRuleContext(IdentifierOrParameterContext.class,0); + public CommandOptionsContext commandOptions() { + return getRuleContext(CommandOptionsContext.class,0); } @SuppressWarnings("this-escape") public RerankCommandContext(ParserRuleContext parent, int invokingState) { @@ -4425,7 +4424,7 @@ public final RerankCommandContext rerankCommand() throws RecognitionException { setState(537); match(WITH); setState(538); - ((RerankCommandContext)_localctx).inferenceId = identifierOrParameter(); + commandOptions(); } break; } @@ -7395,7 +7394,7 @@ private boolean primaryExpression_sempred(PrimaryExpressionContext _localctx, in "q\u0001\u0000\u0000\u0000\u0213\u0214\u0005\u001f\u0000\u0000\u0214s\u0001"+ "\u0000\u0000\u0000\u0215\u0216\u0005\u0011\u0000\u0000\u0216\u0217\u0003"+ "\u008eG\u0000\u0217\u0218\u0005J\u0000\u0000\u0218\u021b\u0003\u0012\t"+ - "\u0000\u0219\u021a\u0005O\u0000\u0000\u021a\u021c\u0003<\u001e\u0000\u021b"+ + "\u0000\u0219\u021a\u0005O\u0000\u0000\u021a\u021c\u0003R)\u0000\u021b"+ "\u0219\u0001\u0000\u0000\u0000\u021b\u021c\u0001\u0000\u0000\u0000\u021c"+ "u\u0001\u0000\u0000\u0000\u021d\u0221\u0005\u0007\u0000\u0000\u021e\u021f"+ "\u0003.\u0017\u0000\u021f\u0220\u0005:\u0000\u0000\u0220\u0222\u0001\u0000"+ diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java index 254f2ca2296a2..3c0a6dffbaa10 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java @@ -723,7 +723,9 @@ public PlanFactory visitRrfCommand(EsqlBaseParser.RrfCommandContext ctx) { @Override public PlanFactory visitRerankCommand(EsqlBaseParser.RerankCommandContext ctx) { Source source = source(ctx); + List rerankFields = visitRerankFields(ctx.rerankFields()); Expression queryText = expression(ctx.queryText); + if (queryText instanceof Literal queryTextLiteral && DataType.isString(queryText.dataType())) { if (queryTextLiteral.value() == null) { throw new ParsingException( @@ -740,18 +742,46 @@ public PlanFactory visitRerankCommand(EsqlBaseParser.RerankCommandContext ctx) { ); } - Literal inferenceId = ctx.inferenceId != null - ? inferenceId(ctx.inferenceId) - : new Literal(source, Rerank.DEFAULT_INFERENCE_ID, KEYWORD); + return p -> visitRerankOptions(new Rerank.Builder(source, p, queryText, rerankFields), ctx.commandOptions()).build(); + } + + private Rerank.Builder visitRerankOptions(Rerank.Builder rerannkBuilder, EsqlBaseParser.CommandOptionsContext ctx) { + if (ctx == null) { + return rerannkBuilder; + } - return p -> new Rerank(source, p, inferenceId, queryText, visitRerankFields(ctx.rerankFields())); + for (var option : ctx.commandOption()) { + String optionName = visitIdentifier(option.identifier()); + if (optionName.equals(Rerank.Builder.INFERENCE_ID_OPTION_NAME)) { + rerannkBuilder.withInferenceId(visitInferenceId(expression(option.primaryExpression()))); + } else if (optionName.equals(Rerank.Builder.SCORE_COLUMN_OPTION_NAME)) { + if (expression(option.primaryExpression()) instanceof UnresolvedAttribute scoreAttribute) { + rerannkBuilder.withScoreColumnAttribute(scoreAttribute); + } else { + throw new ParsingException( + source(option.identifier()), + "Option [{}] expects a valid attribute in RERANK command. [{}] provided.", + option.identifier().getText(), + option.primaryExpression().getText() + ); + } + } else { + throw new ParsingException( + source(option.identifier()), + "Unknow parameter [{}] in RERANK command", + option.identifier().getText() + ); + } + } + + return rerannkBuilder; } @Override public PlanFactory visitCompletionCommand(EsqlBaseParser.CompletionCommandContext ctx) { Source source = source(ctx); Expression prompt = expression(ctx.prompt); - Literal inferenceId = inferenceId(ctx.inferenceId); + Literal inferenceId = visitInferenceId(ctx.inferenceId); Attribute targetField = ctx.targetField == null ? new UnresolvedAttribute(source, Completion.DEFAULT_OUTPUT_FIELD_NAME) : visitQualifiedName(ctx.targetField); @@ -759,27 +789,35 @@ public PlanFactory visitCompletionCommand(EsqlBaseParser.CompletionCommandContex return p -> new Completion(source, p, inferenceId, prompt, targetField); } - public Literal inferenceId(EsqlBaseParser.IdentifierOrParameterContext ctx) { + public Literal visitInferenceId(EsqlBaseParser.IdentifierOrParameterContext ctx) { if (ctx.identifier() != null) { return new Literal(source(ctx), visitIdentifier(ctx.identifier()), KEYWORD); } - if (expression(ctx.parameter()) instanceof Literal literalParam) { - if (literalParam.value() != null) { - return literalParam; + return visitInferenceId(expression(ctx.parameter())); + } + + public Literal visitInferenceId(Expression expression) { + if (expression instanceof Literal literal) { + if (literal.value() == null) { + throw new ParsingException( + expression.source(), + "Query parameter [{}] is null or undefined and cannot be used as inference id", + expression.source().text() + ); } - throw new ParsingException( - source(ctx.parameter()), - "Query parameter [{}] is null or undefined and cannot be used as inference id", - ctx.parameter().getText() - ); + return literal; + } else if (expression instanceof UnresolvedAttribute attribute) { + // Support for unquoted inference id + return new Literal(expression.source(), attribute.name(), KEYWORD); } throw new ParsingException( - source(ctx.parameter()), - "Query parameter [{}] is not a string and cannot be used as inference id", - ctx.parameter().getText() + expression.source(), + "Query parameter [{}] is not a string and cannot be used as inference id [{}]", + expression.source().text(), + expression.getClass() ); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java index fcfcfb4f21d18..9d4915b8a6ea2 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java @@ -18,10 +18,12 @@ import org.elasticsearch.xpack.esql.core.expression.AttributeSet; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.expression.Expressions; +import org.elasticsearch.xpack.esql.core.expression.Literal; import org.elasticsearch.xpack.esql.core.expression.MetadataAttribute; import org.elasticsearch.xpack.esql.core.expression.UnresolvedAttribute; import org.elasticsearch.xpack.esql.core.tree.NodeInfo; import org.elasticsearch.xpack.esql.core.tree.Source; +import org.elasticsearch.xpack.esql.core.type.DataType; import org.elasticsearch.xpack.esql.expression.Order; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; import org.elasticsearch.xpack.esql.plan.QueryPlan; @@ -37,23 +39,17 @@ import static org.elasticsearch.xpack.esql.core.expression.Expressions.asAttributes; import static org.elasticsearch.xpack.esql.expression.NamedExpressions.mergeOutputAttributes; +import static org.elasticsearch.xpack.esql.parser.ParserUtils.source; public class Rerank extends InferencePlan implements SortAgnostic, SurrogateLogicalPlan, TelemetryAware { public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(LogicalPlan.class, "Rerank", Rerank::new); - public static final Object DEFAULT_INFERENCE_ID = ".rerank-v1-elasticsearch"; + public static final String DEFAULT_INFERENCE_ID = ".rerank-v1-elasticsearch"; private final Attribute scoreAttribute; private final Expression queryText; private final List rerankFields; private List lazyOutput; - public Rerank(Source source, LogicalPlan child, Expression inferenceId, Expression queryText, List rerankFields) { - super(source, child, inferenceId); - this.queryText = queryText; - this.rerankFields = rerankFields; - this.scoreAttribute = new UnresolvedAttribute(source, MetadataAttribute.SCORE); - } - public Rerank( Source source, LogicalPlan child, @@ -189,4 +185,38 @@ public List output() { public static boolean planHasAttribute(QueryPlan plan, Attribute attribute) { return plan.outputSet().stream().anyMatch(attr -> attr.equals(attribute)); } + + public static class Builder { + + public static final String INFERENCE_ID_OPTION_NAME = "inferenceId"; + public static final String SCORE_COLUMN_OPTION_NAME = "scoreColumn"; + + private final Source source; + private final LogicalPlan child; + private final Expression queryText; + private final List rerankFields; + private Expression inferenceId = new Literal(Source.EMPTY, Rerank.DEFAULT_INFERENCE_ID, DataType.KEYWORD); + private Attribute scoreAttribute = new UnresolvedAttribute(Source.EMPTY, MetadataAttribute.SCORE); + + public Builder(Source source, LogicalPlan child, Expression queryText, List rerankFields) { + this.source = source; + this.child = child; + this.queryText = queryText; + this.rerankFields = rerankFields; + } + + public Builder withInferenceId(Expression inferenceId) { + this.inferenceId = inferenceId; + return this; + } + + public Builder withScoreColumnAttribute(Attribute scoreAttribute) { + this.scoreAttribute = scoreAttribute; + return this; + } + + public Rerank build() { + return new Rerank(source, child, inferenceId, queryText, rerankFields, scoreAttribute); + } + } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java index 9171f1c9d1dea..4e70a1c001e03 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java @@ -3552,7 +3552,7 @@ public void testResolveRerankInferenceId() { { LogicalPlan plan = analyze( - "FROM books METADATA _score | RERANK \"italian food recipe\" ON title WITH `reranking-inference-id`", + "FROM books METADATA _score | RERANK \"italian food recipe\" ON title WITH inferenceId=`reranking-inference-id`", "mapping-books.json" ); Rerank rerank = as(as(plan, Limit.class).child(), Rerank.class); @@ -3563,7 +3563,7 @@ public void testResolveRerankInferenceId() { VerificationException ve = expectThrows( VerificationException.class, () -> analyze( - "FROM books METADATA _score | RERANK \"italian food recipe\" ON title WITH `completion-inference-id`", + "FROM books METADATA _score | RERANK \"italian food recipe\" ON title WITH inferenceId=`completion-inference-id`", "mapping-books.json" ) @@ -3581,7 +3581,7 @@ public void testResolveRerankInferenceId() { VerificationException ve = expectThrows( VerificationException.class, () -> analyze( - "FROM books METADATA _score | RERANK \"italian food recipe\" ON title WITH `error-inference-id`", + "FROM books METADATA _score | RERANK \"italian food recipe\" ON title WITH inferenceId=`error-inference-id`", "mapping-books.json" ) @@ -3593,7 +3593,7 @@ public void testResolveRerankInferenceId() { VerificationException ve = expectThrows( VerificationException.class, () -> analyze( - "FROM books METADATA _score | RERANK \"italian food recipe\" ON title WITH `unknown-inference-id`", + "FROM books METADATA _score | RERANK \"italian food recipe\" ON title WITH inferenceId=`unknown-inference-id`", "mapping-books.json" ) @@ -3612,7 +3612,7 @@ public void testResolveRerankFields() { | WHERE title:"italian food recipe" OR description:"italian food recipe" | KEEP description, title, year, _score | DROP description - | RERANK "italian food recipe" ON title WITH `reranking-inference-id` + | RERANK "italian food recipe" ON title WITH inferenceId=`reranking-inference-id` """, "mapping-books.json"); Limit limit = as(plan, Limit.class); // Implicit limit added by AddImplicitLimit rule. @@ -3633,11 +3633,14 @@ public void testResolveRerankFields() { { // Multiple fields. - LogicalPlan plan = analyze(""" - FROM books METADATA _score - | WHERE title:"food" - | RERANK "food" ON title, description=SUBSTRING(description, 0, 100), yearRenamed=year WITH `reranking-inference-id` - """, "mapping-books.json"); + LogicalPlan plan = analyze( + """ + FROM books METADATA _score + | WHERE title:"food" + | RERANK "food" ON title, description=SUBSTRING(description, 0, 100), yearRenamed=year WITH inferenceId=`reranking-inference-id` + """, + "mapping-books.json" + ); Limit limit = as(plan, Limit.class); // Implicit limit added by AddImplicitLimit rule. Rerank rerank = as(limit.child(), Rerank.class); @@ -3674,7 +3677,7 @@ public void testResolveRerankFields() { LogicalPlan plan = analyze(""" FROM books METADATA _score | WHERE title:"food" - | RERANK "food" ON title, SUBSTRING(description, 0, 100), yearRenamed=year WITH `reranking-inference-id` + | RERANK "food" ON title, SUBSTRING(description, 0, 100), yearRenamed=year WITH inferenceId=`reranking-inference-id` """, "mapping-books.json"); } catch (ParsingException ex) { assertThat( @@ -3688,7 +3691,7 @@ public void testResolveRerankFields() { VerificationException ve = expectThrows( VerificationException.class, () -> analyze( - "FROM books METADATA _score | RERANK \"italian food recipe\" ON missingField WITH `reranking-inference-id`", + "FROM books METADATA _score | RERANK \"italian food recipe\" ON missingField WITH inferenceId=`reranking-inference-id`", "mapping-books.json" ) @@ -3705,7 +3708,7 @@ public void testResolveRerankScoreField() { LogicalPlan plan = analyze(""" FROM books METADATA _score | WHERE title:"italian food recipe" OR description:"italian food recipe" - | RERANK "italian food recipe" ON title WITH `reranking-inference-id` + | RERANK "italian food recipe" ON title WITH inferenceId=`reranking-inference-id` """, "mapping-books.json"); Limit limit = as(plan, Limit.class); // Implicit limit added by AddImplicitLimit rule. @@ -3723,7 +3726,7 @@ public void testResolveRerankScoreField() { LogicalPlan plan = analyze(""" FROM books | WHERE title:"italian food recipe" OR description:"italian food recipe" - | RERANK "italian food recipe" ON title WITH `reranking-inference-id` + | RERANK "italian food recipe" ON title WITH inferenceId=`reranking-inference-id` """, "mapping-books.json"); Limit limit = as(plan, Limit.class); // Implicit limit added by AddImplicitLimit rule. diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java index 826353560d996..e1d7bbd61821e 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java @@ -3356,7 +3356,7 @@ public void testRerankDefaultInferenceId() { public void testRerankSingleField() { assumeTrue("RERANK requires corresponding capability", EsqlCapabilities.Cap.RERANK.isEnabled()); - var plan = processingCommand("RERANK \"query text\" ON title WITH inferenceID"); + var plan = processingCommand("RERANK \"query text\" ON title WITH inferenceId=inferenceID"); var rerank = as(plan, Rerank.class); assertThat(rerank.queryText(), equalTo(literalString("query text"))); @@ -3367,7 +3367,7 @@ public void testRerankSingleField() { public void testRerankMultipleFields() { assumeTrue("RERANK requires corresponding capability", EsqlCapabilities.Cap.RERANK.isEnabled()); - var plan = processingCommand("RERANK \"query text\" ON title, description, authors_renamed=authors WITH inferenceID"); + var plan = processingCommand("RERANK \"query text\" ON title, description, authors_renamed=authors WITH inferenceId=inferenceID"); var rerank = as(plan, Rerank.class); assertThat(rerank.queryText(), equalTo(literalString("query text"))); @@ -3387,7 +3387,9 @@ public void testRerankMultipleFields() { public void testRerankComputedFields() { assumeTrue("RERANK requires corresponding capability", EsqlCapabilities.Cap.RERANK.isEnabled()); - var plan = processingCommand("RERANK \"query text\" ON title, short_description = SUBSTRING(description, 0, 100) WITH inferenceID"); + var plan = processingCommand( + "RERANK \"query text\" ON title, short_description = SUBSTRING(description, 0, 100) WITH inferenceId=inferenceID" + ); var rerank = as(plan, Rerank.class); assertThat(rerank.queryText(), equalTo(literalString("query text"))); @@ -3407,7 +3409,7 @@ public void testRerankWithPositionalParameters() { assumeTrue("RERANK requires corresponding capability", EsqlCapabilities.Cap.RERANK.isEnabled()); var queryParams = new QueryParams(List.of(paramAsConstant(null, "query text"), paramAsConstant(null, "reranker"))); - var rerank = as(parser.createStatement("row a = 1 | RERANK ? ON title WITH ?", queryParams), Rerank.class); + var rerank = as(parser.createStatement("row a = 1 | RERANK ? ON title WITH inferenceId=?", queryParams), Rerank.class); assertThat(rerank.queryText(), equalTo(literalString("query text"))); assertThat(rerank.inferenceId(), equalTo(literalString("reranker"))); @@ -3418,7 +3420,10 @@ public void testRerankWithNamedParameters() { assumeTrue("RERANK requires corresponding capability", EsqlCapabilities.Cap.RERANK.isEnabled()); var queryParams = new QueryParams(List.of(paramAsConstant("queryText", "query text"), paramAsConstant("inferenceId", "reranker"))); - var rerank = as(parser.createStatement("row a = 1 | RERANK ?queryText ON title WITH ?inferenceId", queryParams), Rerank.class); + var rerank = as( + parser.createStatement("row a = 1 | RERANK ?queryText ON title WITH inferenceId=?inferenceId", queryParams), + Rerank.class + ); assertThat(rerank.queryText(), equalTo(literalString("query text"))); assertThat(rerank.inferenceId(), equalTo(literalString("reranker"))); From 2ac85c1a01ca6dd4d9e2c3dfaba5003142e28465 Mon Sep 17 00:00:00 2001 From: afoucret Date: Mon, 16 Jun 2025 19:56:00 +0200 Subject: [PATCH 03/10] Lint --- .../org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java index 4e70a1c001e03..97183ed15bff7 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java @@ -3637,7 +3637,8 @@ public void testResolveRerankFields() { """ FROM books METADATA _score | WHERE title:"food" - | RERANK "food" ON title, description=SUBSTRING(description, 0, 100), yearRenamed=year WITH inferenceId=`reranking-inference-id` + | RERANK "food" ON title, description=SUBSTRING(description, 0, 100), yearRenamed=year + WITH inferenceId=`reranking-inference-id` """, "mapping-books.json" ); From d388ff8841ebe7bee7a688c79c1f8cac60b4af32 Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 17 Jun 2025 12:12:36 +0200 Subject: [PATCH 04/10] Update RERANK: - Not sorting the data anymore - Output the score in the specified column - Applied additional logical plan optimizations since the plan is now a generating plan (because we removed the SORT clause) - Updated tests --- .../src/main/resources/rerank.csv-spec | 126 ++++++++++++------ .../esql/optimizer/LogicalPlanOptimizer.java | 4 +- .../logical/PushDownAndCombineFilters.java | 8 +- .../logical/PushDownAndCombineLimits.java | 4 +- ...letion.java => PushDownInferencePlan.java} | 6 +- .../xpack/esql/parser/LogicalPlanBuilder.java | 52 +++++--- .../plan/logical/inference/Completion.java | 9 +- .../plan/logical/inference/InferencePlan.java | 7 +- .../esql/plan/logical/inference/Rerank.java | 51 ++++--- .../plan/physical/inference/RerankExec.java | 17 +-- .../esql/planner/LocalExecutionPlanner.java | 24 ++-- .../xpack/esql/analysis/AnalyzerTests.java | 52 ++++++-- .../optimizer/LogicalPlanOptimizerTests.java | 19 ++- .../PushDownAndCombineFiltersTests.java | 56 +++++++- .../PushDownAndCombineLimitsTests.java | 22 ++- .../esql/parser/StatementParserTests.java | 89 ++++++++++++- 16 files changed, 398 insertions(+), 148 deletions(-) rename x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/{PushDownCompletion.java => PushDownInferencePlan.java} (67%) diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/rerank.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/rerank.csv-spec index 6c80d019e86d3..fb09464759a23 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/rerank.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/rerank.csv-spec @@ -3,21 +3,62 @@ // This makes the output more predictable which is helpful here. -reranker using a single field +reranker using a single field, overwrite existing _score column required_capability: rerank required_capability: match_operator_colon FROM books METADATA _score | WHERE title:"war and peace" AND author:"Tolstoy" +| SORT _score DESC, book_no ASC | RERANK "war and peace" ON title WITH inferenceId=test_reranker -| KEEP book_no, title, author +| EVAL _score=ROUND(_score, 2) +| KEEP book_no, title, author, _score ; -book_no:keyword | title:text | author:text -5327 | War and Peace | Leo Tolstoy -4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] -9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo -2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy +book_no:keyword | title:text | author:text | _score:double +5327 | War and Peace | Leo Tolstoy | 0.08 +4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.03 +9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.03 +2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy | 0.02 +; + +reranker using a single field, create a mew column +required_capability: rerank +required_capability: match_operator_colon + +FROM books METADATA _score +| WHERE title:"war and peace" AND author:"Tolstoy" +| SORT _score DESC, book_no ASC +| RERANK "war and peace" ON title WITH inferenceId=test_reranker, scoreColumn=rerank_score +| EVAL _score=ROUND(_score, 2), rerank_score=ROUND(rerank_score, 2) +| KEEP book_no, title, author, rerank_score +; + +book_no:keyword | title:text | author:text | rerank_score:double +5327 | War and Peace | Leo Tolstoy | 0.08 +4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.03 +9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.03 +2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy | 0.02 +; + +reranker using a single field, create a mew column, sort by rerank_score +required_capability: rerank +required_capability: match_operator_colon + +FROM books METADATA _score +| WHERE title:"war and peace" AND author:"Tolstoy" +| SORT _score DESC +| RERANK "war and peace" ON title WITH inferenceId=test_reranker, scoreColumn=rerank_score +| EVAL _score=ROUND(_score, 2), rerank_score=ROUND(rerank_score, 2) +| SORT rerank_score, _score ASC, book_no ASC +| KEEP book_no, title, author, rerank_score +; + +book_no:keyword | title:text | author:text | rerank_score:double +2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy | 0.02 +9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.03 +4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.03 +5327 | War and Peace | Leo Tolstoy | 0.08 ; @@ -27,15 +68,17 @@ required_capability: match_operator_colon FROM books METADATA _score | WHERE title:"war and peace" AND author:"Tolstoy" -| RERANK "war and peace" ON title, author inferenceId=test_reranker -| KEEP book_no, title, author +| RERANK "war and peace" ON title, author WITH inferenceId=test_reranker +| EVAL _score=ROUND(_score, 2) +| SORT _score DESC, book_no ASC +| KEEP book_no, title, author, _score ; -book_no:keyword | title:text | author:text -5327 | War and Peace | Leo Tolstoy -9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo -2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy -4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] +book_no:keyword | title:text | author:text | _score:double +5327 | War and Peace | Leo Tolstoy | 0.02 +2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy | 0.01 +4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.01 +9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.01 ; @@ -45,16 +88,18 @@ required_capability: match_operator_colon FROM books METADATA _score | WHERE title:"war and peace" AND author:"Tolstoy" -| SORT _score DESC +| SORT _score DESC, book_no ASC | LIMIT 3 -| RERANK "war and peace" ON title inferenceId=test_reranker -| KEEP book_no, title, author +| RERANK "war and peace" ON title WITH inferenceId=test_reranker +| EVAL _score=ROUND(_score, 2) +| SORT _score DESC, book_no ASC +| KEEP book_no, title, author, _score ; -book_no:keyword | title:text | author:text -5327 | War and Peace | Leo Tolstoy -4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] -9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo +book_no:keyword | title:text | author:text | _score:double +5327 | War and Peace | Leo Tolstoy | 0.08 +4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.03 +9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.03 ; @@ -64,15 +109,17 @@ required_capability: match_operator_colon FROM books METADATA _score | WHERE title:"war and peace" AND author:"Tolstoy" -| RERANK "war and peace" ON title inferenceId=test_reranker -| KEEP book_no, title, author +| RERANK "war and peace" ON title WITH inferenceId=test_reranker +| EVAL _score=ROUND(_score, 2) +| SORT _score DESC, book_no ASC +| KEEP book_no, title, author, _score | LIMIT 3 ; -book_no:keyword | title:text | author:text -5327 | War and Peace | Leo Tolstoy -4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] -9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo +book_no:keyword | title:text | author:text | _score:double +5327 | War and Peace | Leo Tolstoy | 0.08 +4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.03 +9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.03 ; @@ -82,16 +129,17 @@ required_capability: match_operator_colon FROM books | WHERE title:"war and peace" AND author:"Tolstoy" -| RERANK "war and peace" ON title inferenceId=test_reranker -| KEEP book_no, title, author +| RERANK "war and peace" ON title WITH inferenceId=test_reranker +| EVAL _score=ROUND(_score, 2) +| KEEP book_no, title, author, _score | SORT author, title | LIMIT 3 ; -book_no:keyword | title:text | author:text -4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] -2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy -5327 | War and Peace | Leo Tolstoy +book_no:keyword | title:text | author:text | _score:double +4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.03 +2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy | 0.02 +5327 | War and Peace | Leo Tolstoy | 0.08 ; @@ -105,12 +153,14 @@ FROM books METADATA _id, _index, _score | FORK ( WHERE title:"Tolkien" | SORT _score, _id DESC | LIMIT 3 ) ( WHERE author:"Tolkien" | SORT _score, _id DESC | LIMIT 3 ) | RRF -| RERANK "Tolkien" ON title inferenceId=test_reranker +| RERANK "Tolkien" ON title WITH inferenceId=test_reranker +| EVAL _score=ROUND(_score, 2) +| SORT _score DESC, book_no ASC | LIMIT 2 -| KEEP book_no, title, author +| KEEP book_no, title, author, _score ; -book_no:keyword | title:keyword | author:keyword -5335 | Letters of J R R Tolkien | J.R.R. Tolkien -2130 | The J. R. R. Tolkien Audio Collection | [Christopher Tolkien, John Ronald Reuel Tolkien] +book_no:keyword | title:keyword | author:keyword | _score:double +5335 | Letters of J R R Tolkien | J.R.R. Tolkien | 0.04 +2130 | The J. R. R. Tolkien Audio Collection | [Christopher Tolkien, John Ronald Reuel Tolkien] | 0.03 ; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizer.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizer.java index 32c764ff29f76..3d0b550ca9bfc 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizer.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizer.java @@ -39,9 +39,9 @@ import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownAndCombineLimits; import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownAndCombineOrderBy; import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownAndCombineSample; -import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownCompletion; import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownEnrich; import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownEval; +import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownInferencePlan; import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownRegexExtract; import org.elasticsearch.xpack.esql.optimizer.rules.logical.RemoveStatsOverride; import org.elasticsearch.xpack.esql.optimizer.rules.logical.ReplaceAggregateAggExpressionWithEval; @@ -194,7 +194,7 @@ protected static Batch operators() { new PushDownAndCombineLimits(), new PushDownAndCombineFilters(), new PushDownAndCombineSample(), - new PushDownCompletion(), + new PushDownInferencePlan(), new PushDownEval(), new PushDownRegexExtract(), new PushDownEnrich(), diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineFilters.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineFilters.java index d1b425c5587e2..6b4411fafbbfe 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineFilters.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineFilters.java @@ -24,7 +24,7 @@ import org.elasticsearch.xpack.esql.plan.logical.Project; import org.elasticsearch.xpack.esql.plan.logical.RegexExtract; import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan; -import org.elasticsearch.xpack.esql.plan.logical.inference.Completion; +import org.elasticsearch.xpack.esql.plan.logical.inference.InferencePlan; import org.elasticsearch.xpack.esql.plan.logical.join.InlineJoin; import org.elasticsearch.xpack.esql.plan.logical.join.Join; import org.elasticsearch.xpack.esql.plan.logical.join.JoinTypes; @@ -72,10 +72,10 @@ protected LogicalPlan rule(Filter filter) { // Push down filters that do not rely on attributes created by RegexExtract var attributes = AttributeSet.of(Expressions.asAttributes(re.extractedFields())); plan = maybePushDownPastUnary(filter, re, attributes::contains, NO_OP); - } else if (child instanceof Completion completion) { + } else if (child instanceof InferencePlan inferencePlan) { // Push down filters that do not rely on attributes created by Cpmpletion - var attributes = AttributeSet.of(completion.generatedAttributes()); - plan = maybePushDownPastUnary(filter, completion, attributes::contains, NO_OP); + var attributes = AttributeSet.of(inferencePlan.generatedAttributes()); + plan = maybePushDownPastUnary(filter, inferencePlan, attributes::contains, NO_OP); } else if (child instanceof Enrich enrich) { // Push down filters that do not rely on attributes created by Enrich var attributes = AttributeSet.of(Expressions.asAttributes(enrich.enrichFields())); diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineLimits.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineLimits.java index 67e2edef667b4..7bad50abd46de 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineLimits.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineLimits.java @@ -17,7 +17,7 @@ import org.elasticsearch.xpack.esql.plan.logical.Project; import org.elasticsearch.xpack.esql.plan.logical.RegexExtract; import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan; -import org.elasticsearch.xpack.esql.plan.logical.inference.Completion; +import org.elasticsearch.xpack.esql.plan.logical.inference.InferencePlan; import org.elasticsearch.xpack.esql.plan.logical.join.Join; import org.elasticsearch.xpack.esql.plan.logical.join.JoinTypes; @@ -43,7 +43,7 @@ public LogicalPlan rule(Limit limit, LogicalOptimizerContext ctx) { || unary instanceof Project || unary instanceof RegexExtract || unary instanceof Enrich - || unary instanceof Completion) { + || unary instanceof InferencePlan) { return unary.replaceChild(limit.replaceChild(unary.child())); } else if (unary instanceof MvExpand) { // MV_EXPAND can increase the number of rows, so we cannot just push the limit down diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownCompletion.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownInferencePlan.java similarity index 67% rename from x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownCompletion.java rename to x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownInferencePlan.java index d74e90fb0569f..20e21adb89142 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownCompletion.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownInferencePlan.java @@ -8,11 +8,11 @@ package org.elasticsearch.xpack.esql.optimizer.rules.logical; import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; -import org.elasticsearch.xpack.esql.plan.logical.inference.Completion; +import org.elasticsearch.xpack.esql.plan.logical.inference.InferencePlan; -public final class PushDownCompletion extends OptimizerRules.OptimizerRule { +public final class PushDownInferencePlan extends OptimizerRules.OptimizerRule> { @Override - protected LogicalPlan rule(Completion p) { + protected LogicalPlan rule(InferencePlan p) { return PushDownUtils.pushGeneratingPlanPastProjectAndOrderBy(p); } } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java index 3c0a6dffbaa10..0432f7c6c81db 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java @@ -745,26 +745,17 @@ public PlanFactory visitRerankCommand(EsqlBaseParser.RerankCommandContext ctx) { return p -> visitRerankOptions(new Rerank.Builder(source, p, queryText, rerankFields), ctx.commandOptions()).build(); } - private Rerank.Builder visitRerankOptions(Rerank.Builder rerannkBuilder, EsqlBaseParser.CommandOptionsContext ctx) { + private Rerank.Builder visitRerankOptions(Rerank.Builder rerankBuilder, EsqlBaseParser.CommandOptionsContext ctx) { if (ctx == null) { - return rerannkBuilder; + return rerankBuilder; } for (var option : ctx.commandOption()) { String optionName = visitIdentifier(option.identifier()); - if (optionName.equals(Rerank.Builder.INFERENCE_ID_OPTION_NAME)) { - rerannkBuilder.withInferenceId(visitInferenceId(expression(option.primaryExpression()))); - } else if (optionName.equals(Rerank.Builder.SCORE_COLUMN_OPTION_NAME)) { - if (expression(option.primaryExpression()) instanceof UnresolvedAttribute scoreAttribute) { - rerannkBuilder.withScoreColumnAttribute(scoreAttribute); - } else { - throw new ParsingException( - source(option.identifier()), - "Option [{}] expects a valid attribute in RERANK command. [{}] provided.", - option.identifier().getText(), - option.primaryExpression().getText() - ); - } + if (optionName.equals(Rerank.INFERENCE_ID_OPTION_NAME)) { + rerankBuilder.withInferenceId(visitInferenceId(expression(option.primaryExpression()))); + } else if (optionName.equals(Rerank.SCORE_COLUMN_OPTION_NAME)) { + rerankBuilder.withScoreAttribute(visitRerankScoreAttribute(option)); } else { throw new ParsingException( source(option.identifier()), @@ -774,7 +765,7 @@ private Rerank.Builder visitRerankOptions(Rerank.Builder rerannkBuilder, EsqlBas } } - return rerannkBuilder; + return rerankBuilder; } @Override @@ -789,6 +780,33 @@ public PlanFactory visitCompletionCommand(EsqlBaseParser.CompletionCommandContex return p -> new Completion(source, p, inferenceId, prompt, targetField); } + public UnresolvedAttribute visitRerankScoreAttribute(EsqlBaseParser.CommandOptionContext ctx) { + if (ctx.primaryExpression() == null) { + throw new ParsingException(source(ctx), "Parameter [{}] is null or undefined", ctx.identifier().getText()); + } + + Expression optionValue = expression(ctx.primaryExpression()); + + if (optionValue instanceof UnresolvedAttribute scoreAttribute) { + return scoreAttribute; + } else if (optionValue instanceof Literal literal) { + if (literal.value() == null) { + throw new ParsingException(optionValue.source(), "Parameter [{}] is null or undefined", ctx.identifier().getText()); + } + + if (literal.value() instanceof String attributeName) { + return new UnresolvedAttribute(literal.source(), attributeName); + } + } + + throw new ParsingException( + source(ctx), + "Option [{}] expects a valid attribute in RERANK command. [{}] provided.", + ctx.identifier().getText(), + ctx.primaryExpression().getText() + ); + } + public Literal visitInferenceId(EsqlBaseParser.IdentifierOrParameterContext ctx) { if (ctx.identifier() != null) { return new Literal(source(ctx), visitIdentifier(ctx.identifier()), KEYWORD); @@ -802,7 +820,7 @@ public Literal visitInferenceId(Expression expression) { if (literal.value() == null) { throw new ParsingException( expression.source(), - "Query parameter [{}] is null or undefined and cannot be used as inference id", + "Parameter [{}] is null or undefined and cannot be used as inference id", expression.source().text() ); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Completion.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Completion.java index a577229f51aef..c4115caf111d1 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Completion.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Completion.java @@ -22,9 +22,7 @@ import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.core.type.DataType; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; -import org.elasticsearch.xpack.esql.plan.GeneratingPlan; import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; -import org.elasticsearch.xpack.esql.plan.logical.SortAgnostic; import java.io.IOException; import java.util.List; @@ -34,12 +32,7 @@ import static org.elasticsearch.xpack.esql.core.type.DataType.TEXT; import static org.elasticsearch.xpack.esql.expression.NamedExpressions.mergeOutputAttributes; -public class Completion extends InferencePlan - implements - GeneratingPlan, - SortAgnostic, - TelemetryAware, - PostAnalysisVerificationAware { +public class Completion extends InferencePlan implements TelemetryAware, PostAnalysisVerificationAware { public static final String DEFAULT_OUTPUT_FIELD_NAME = "completion"; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/InferencePlan.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/InferencePlan.java index 3d199fba495c6..620e8726865d6 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/InferencePlan.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/InferencePlan.java @@ -12,13 +12,18 @@ import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.expression.UnresolvedAttribute; import org.elasticsearch.xpack.esql.core.tree.Source; +import org.elasticsearch.xpack.esql.plan.GeneratingPlan; import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; +import org.elasticsearch.xpack.esql.plan.logical.SortAgnostic; import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan; import java.io.IOException; import java.util.Objects; -public abstract class InferencePlan> extends UnaryPlan { +public abstract class InferencePlan> extends UnaryPlan + implements + SortAgnostic, + GeneratingPlan> { private final Expression inferenceId; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java index 9d4915b8a6ea2..3630993c39828 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java @@ -20,17 +20,13 @@ import org.elasticsearch.xpack.esql.core.expression.Expressions; import org.elasticsearch.xpack.esql.core.expression.Literal; import org.elasticsearch.xpack.esql.core.expression.MetadataAttribute; +import org.elasticsearch.xpack.esql.core.expression.NameId; import org.elasticsearch.xpack.esql.core.expression.UnresolvedAttribute; import org.elasticsearch.xpack.esql.core.tree.NodeInfo; import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.core.type.DataType; -import org.elasticsearch.xpack.esql.expression.Order; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; -import org.elasticsearch.xpack.esql.plan.QueryPlan; import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; -import org.elasticsearch.xpack.esql.plan.logical.OrderBy; -import org.elasticsearch.xpack.esql.plan.logical.SortAgnostic; -import org.elasticsearch.xpack.esql.plan.logical.SurrogateLogicalPlan; import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan; import java.io.IOException; @@ -41,10 +37,13 @@ import static org.elasticsearch.xpack.esql.expression.NamedExpressions.mergeOutputAttributes; import static org.elasticsearch.xpack.esql.parser.ParserUtils.source; -public class Rerank extends InferencePlan implements SortAgnostic, SurrogateLogicalPlan, TelemetryAware { +public class Rerank extends InferencePlan implements TelemetryAware { public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(LogicalPlan.class, "Rerank", Rerank::new); public static final String DEFAULT_INFERENCE_ID = ".rerank-v1-elasticsearch"; + public static final String INFERENCE_ID_OPTION_NAME = "inferenceId"; + public static final String SCORE_COLUMN_OPTION_NAME = "scoreColumn"; + private final Attribute scoreAttribute; private final Expression queryText; private final List rerankFields; @@ -125,13 +124,25 @@ public UnaryPlan replaceChild(LogicalPlan newChild) { @Override protected AttributeSet computeReferences() { - AttributeSet.Builder refs = computeReferences(rerankFields).asBuilder(); + return computeReferences(rerankFields); + } + + public List generatedAttributes() { + return List.of(scoreAttribute); + } + + @Override + public Rerank withGeneratedNames(List newNames) { + checkNumberOfNewNames(newNames); + return new Rerank(source(), child(), inferenceId(), queryText, rerankFields, this.renameScoreAttribute(newNames.get(0))); + } - if (planHasAttribute(child(), scoreAttribute)) { - refs.add(scoreAttribute); + private Attribute renameScoreAttribute(String newName) { + if (newName.equals(scoreAttribute.name())) { + return scoreAttribute; } - return refs.build(); + return scoreAttribute.withName(newName).withId(new NameId()); } public static AttributeSet computeReferences(List fields) { @@ -165,32 +176,16 @@ public int hashCode() { return Objects.hash(super.hashCode(), queryText, rerankFields, scoreAttribute); } - @Override - public LogicalPlan surrogate() { - Order sortOrder = new Order(source(), scoreAttribute, Order.OrderDirection.DESC, Order.NullsPosition.ANY); - return new OrderBy(source(), this, List.of(sortOrder)); - } - @Override public List output() { if (lazyOutput == null) { - lazyOutput = planHasAttribute(child(), scoreAttribute) - ? child().output() - : mergeOutputAttributes(List.of(scoreAttribute), child().output()); + lazyOutput = mergeOutputAttributes(List.of(scoreAttribute), child().output()); } - return lazyOutput; } - public static boolean planHasAttribute(QueryPlan plan, Attribute attribute) { - return plan.outputSet().stream().anyMatch(attr -> attr.equals(attribute)); - } - public static class Builder { - public static final String INFERENCE_ID_OPTION_NAME = "inferenceId"; - public static final String SCORE_COLUMN_OPTION_NAME = "scoreColumn"; - private final Source source; private final LogicalPlan child; private final Expression queryText; @@ -210,7 +205,7 @@ public Builder withInferenceId(Expression inferenceId) { return this; } - public Builder withScoreColumnAttribute(Attribute scoreAttribute) { + public Builder withScoreAttribute(Attribute scoreAttribute) { this.scoreAttribute = scoreAttribute; return this; } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/inference/RerankExec.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/inference/RerankExec.java index 4570775af2ed1..ad852d0ac20db 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/inference/RerankExec.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/inference/RerankExec.java @@ -26,7 +26,6 @@ import java.util.Objects; import static org.elasticsearch.xpack.esql.expression.NamedExpressions.mergeOutputAttributes; -import static org.elasticsearch.xpack.esql.plan.logical.inference.Rerank.planHasAttribute; public class RerankExec extends InferenceExec { @@ -39,6 +38,7 @@ public class RerankExec extends InferenceExec { private final Expression queryText; private final List rerankFields; private final Attribute scoreAttribute; + private List lazyOutput; public RerankExec( Source source, @@ -102,22 +102,15 @@ public UnaryExec replaceChild(PhysicalPlan newChild) { @Override public List output() { - if (planHasAttribute(child(), scoreAttribute)) { - return child().output(); + if (lazyOutput == null) { + lazyOutput = mergeOutputAttributes(List.of(scoreAttribute), child().output()); } - - return mergeOutputAttributes(List.of(scoreAttribute), child().output()); + return lazyOutput; } @Override protected AttributeSet computeReferences() { - AttributeSet.Builder refs = Rerank.computeReferences(rerankFields).asBuilder(); - - if (planHasAttribute(child(), scoreAttribute)) { - refs.add(scoreAttribute); - } - - return refs.build(); + return Rerank.computeReferences(rerankFields); } @Override diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java index db2862234c136..a8a20674f42b1 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java @@ -616,18 +616,22 @@ private PhysicalOperation planEnrich(EnrichExec enrich, LocalExecutionPlannerCon private PhysicalOperation planRerank(RerankExec rerank, LocalExecutionPlannerContext context) { PhysicalOperation source = plan(rerank.child(), context); - Map rerankFieldsEvaluatorSuppliers = Maps - .newLinkedHashMapWithExpectedSize(rerank.rerankFields().size()); - - for (var rerankField : rerank.rerankFields()) { - rerankFieldsEvaluatorSuppliers.put( - new ColumnInfoImpl(rerankField.name(), rerankField.dataType(), null), - EvalMapper.toEvaluator(context.foldCtx(), rerankField.child(), source.layout) - ); + EvalOperator.ExpressionEvaluator.Factory rowEncoderFactory; + if (rerank.rerankFields().size() > 1) { + Map rerankFieldsEvaluatorSuppliers = Maps + .newLinkedHashMapWithExpectedSize(rerank.rerankFields().size()); + + for (var rerankField : rerank.rerankFields()) { + rerankFieldsEvaluatorSuppliers.put( + new ColumnInfoImpl(rerankField.name(), rerankField.dataType(), null), + EvalMapper.toEvaluator(context.foldCtx(), rerankField.child(), source.layout) + ); + } + rowEncoderFactory = XContentRowEncoder.yamlRowEncoderFactory(rerankFieldsEvaluatorSuppliers); + } else { + rowEncoderFactory = EvalMapper.toEvaluator(context.foldCtx(), rerank.rerankFields().get(0).child(), source.layout); } - XContentRowEncoder.Factory rowEncoderFactory = XContentRowEncoder.yamlRowEncoderFactory(rerankFieldsEvaluatorSuppliers); - String inferenceId = BytesRefs.toString(rerank.inferenceId().fold(context.foldCtx)); String queryText = BytesRefs.toString(rerank.queryText().fold(context.foldCtx)); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java index 478286c23e375..dfcc11ec8b70b 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java @@ -124,6 +124,7 @@ import static org.elasticsearch.xpack.esql.core.type.DataType.DATETIME; import static org.elasticsearch.xpack.esql.core.type.DataType.DATE_NANOS; import static org.elasticsearch.xpack.esql.core.type.DataType.DATE_PERIOD; +import static org.elasticsearch.xpack.esql.core.type.DataType.DOUBLE; import static org.elasticsearch.xpack.esql.core.type.DataType.LONG; import static org.elasticsearch.xpack.esql.core.type.DataType.UNSUPPORTED; import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.dateTimeToString; @@ -3639,15 +3640,12 @@ public void testResolveRerankFields() { { // Multiple fields. - LogicalPlan plan = analyze( - """ - FROM books METADATA _score - | WHERE title:"food" - | RERANK "food" ON title, description=SUBSTRING(description, 0, 100), yearRenamed=year - WITH inferenceId=`reranking-inference-id` - """, - "mapping-books.json" - ); + LogicalPlan plan = analyze(""" + FROM books METADATA _score + | WHERE title:"food" + | RERANK "food" ON title, description=SUBSTRING(description, 0, 100), yearRenamed=year + WITH inferenceId=`reranking-inference-id` + """, "mapping-books.json"); Limit limit = as(plan, Limit.class); // Implicit limit added by AddImplicitLimit rule. Rerank rerank = as(limit.child(), Rerank.class); @@ -3745,6 +3743,42 @@ public void testResolveRerankScoreField() { assertThat(rerank.scoreAttribute(), equalTo(MetadataAttribute.create(EMPTY, MetadataAttribute.SCORE))); assertThat(rerank.output(), hasItem(rerank.scoreAttribute())); } + + { + // When using a custom fields that does not exist + LogicalPlan plan = analyze(""" + FROM books METADATA _score + | WHERE title:"italian food recipe" OR description:"italian food recipe" + | RERANK "italian food recipe" ON title WITH inferenceId=`reranking-inference-id`, scoreColumn=rerank_score + """, "mapping-books.json"); + + Limit limit = as(plan, Limit.class); // Implicit limit added by AddImplicitLimit rule. + Rerank rerank = as(limit.child(), Rerank.class); + + Attribute scoreAttribute = rerank.scoreAttribute(); + assertThat(scoreAttribute.name(), equalTo("rerank_score")); + assertThat(scoreAttribute.dataType(), equalTo(DOUBLE)); + assertThat(rerank.output(), hasItem(scoreAttribute)); + } + + { + // When using a custom fields that already exists + LogicalPlan plan = analyze(""" + FROM books METADATA _score + | WHERE title:"italian food recipe" OR description:"italian food recipe" + | EVAL rerank_score = _score + | RERANK "italian food recipe" ON title WITH inferenceId=`reranking-inference-id`, scoreColumn=rerank_score + """, "mapping-books.json"); + + Limit limit = as(plan, Limit.class); // Implicit limit added by AddImplicitLimit rule. + Rerank rerank = as(limit.child(), Rerank.class); + + Attribute scoreAttribute = rerank.scoreAttribute(); + assertThat(scoreAttribute.name(), equalTo("rerank_score")); + assertThat(scoreAttribute.dataType(), equalTo(DOUBLE)); + assertThat(rerank.output(), hasItem(scoreAttribute)); + assertThat(rerank.child().output().stream().anyMatch(scoreAttribute::equals), is(true)); + } } public void testResolveCompletionInferenceId() { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java index 6d631283aee05..bdc258f3bd0ba 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java @@ -100,9 +100,9 @@ import org.elasticsearch.xpack.esql.optimizer.rules.logical.OptimizerRules; import org.elasticsearch.xpack.esql.optimizer.rules.logical.PruneRedundantOrderBy; import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownAndCombineLimits; -import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownCompletion; import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownEnrich; import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownEval; +import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownInferencePlan; import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownRegexExtract; import org.elasticsearch.xpack.esql.optimizer.rules.logical.SplitInWithFoldableValue; import org.elasticsearch.xpack.esql.parser.EsqlParser; @@ -127,6 +127,7 @@ import org.elasticsearch.xpack.esql.plan.logical.TopN; import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan; import org.elasticsearch.xpack.esql.plan.logical.inference.Completion; +import org.elasticsearch.xpack.esql.plan.logical.inference.Rerank; import org.elasticsearch.xpack.esql.plan.logical.join.InlineJoin; import org.elasticsearch.xpack.esql.plan.logical.join.Join; import org.elasticsearch.xpack.esql.plan.logical.join.JoinConfig; @@ -5655,8 +5656,20 @@ record PushdownShadowingGeneratingPlanTestCase( new Concat(EMPTY, randomLiteral(TEXT), List.of(attr)), new ReferenceAttribute(EMPTY, "y", KEYWORD) ), - new PushDownCompletion() - ) }; + new PushDownInferencePlan() + ), + // | RERANK "some text" ON x WITH inferenceID=inferenceID, scoreColumn=y + new PushdownShadowingGeneratingPlanTestCase( + (plan, attr) -> new Rerank( + EMPTY, + plan, + randomLiteral(TEXT), + randomLiteral(TEXT), + List.of(new Alias(EMPTY, attr.name(), attr)), + new ReferenceAttribute(EMPTY, "y", KEYWORD) + ), + new PushDownInferencePlan() + ), }; /** * Consider diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineFiltersTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineFiltersTests.java index 7bf8256ccd9f6..474da5def3e7d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineFiltersTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineFiltersTests.java @@ -14,6 +14,7 @@ import org.elasticsearch.xpack.esql.core.expression.Attribute; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.expression.FieldAttribute; +import org.elasticsearch.xpack.esql.core.expression.MetadataAttribute; import org.elasticsearch.xpack.esql.core.type.DataType; import org.elasticsearch.xpack.esql.expression.function.aggregate.Count; import org.elasticsearch.xpack.esql.expression.function.fulltext.Match; @@ -32,6 +33,7 @@ import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; import org.elasticsearch.xpack.esql.plan.logical.Project; import org.elasticsearch.xpack.esql.plan.logical.inference.Completion; +import org.elasticsearch.xpack.esql.plan.logical.inference.Rerank; import org.elasticsearch.xpack.esql.plan.logical.local.EsqlProject; import java.util.ArrayList; @@ -245,8 +247,8 @@ public void testSelectivelyPushDownFilterPastFunctionAgg() { assertEquals(expected, new PushDownAndCombineFilters().apply(fb)); } - // from ... | where a > 1 | COMPLETION completion="some prompt" WITH reranker | where b < 2 and match(completion, some text) - // => ... | where a > 1 AND b < 2| COMPLETION completion="some prompt" WITH reranker | match(completion, some text) + // from ... | where a > 1 | COMPLETION completion="some prompt" WITH inferenceId | where b < 2 and match(completion, some text) + // => ... | where a > 1 AND b < 2| COMPLETION completion="some prompt" WITH inferenceId | where match(completion, some text) public void testPushDownFilterPastCompletion() { FieldAttribute a = getFieldAttribute("a"); FieldAttribute b = getFieldAttribute("b"); @@ -282,13 +284,57 @@ public void testPushDownFilterPastCompletion() { assertEquals(expectedOptimizedPlan, new PushDownAndCombineFilters().apply(filterB)); } + // from ... | where a > 1 | RERANK "query" ON title WITH inferenceId | where b < 2 and _score > 1 + // => ... | where a > 1 AND b < 2| RERANK "query" ON title WITH inferenceId | where _score > 1 + public void testPushDownFilterPastRerank() { + FieldAttribute a = getFieldAttribute("a"); + FieldAttribute b = getFieldAttribute("b"); + EsRelation relation = relation(List.of(a, b)); + + GreaterThan conditionA = greaterThanOf(getFieldAttribute("a"), ONE); + Filter filterA = new Filter(EMPTY, relation, conditionA); + + Rerank rerank = rerank(filterA); + + LessThan conditionB = lessThanOf(getFieldAttribute("b"), TWO); + GreaterThan scoreCondition = greaterThanOf(rerank.scoreAttribute(), ONE); + + Filter filterB = new Filter(EMPTY, rerank, new And(EMPTY, conditionB, scoreCondition)); + + LogicalPlan expectedOptimizedPlan = new Filter( + EMPTY, + new Rerank( + EMPTY, + new Filter(EMPTY, relation, new And(EMPTY, conditionA, conditionB)), + rerank.inferenceId(), + rerank.queryText(), + rerank.rerankFields(), + rerank.scoreAttribute() + ), + scoreCondition + ); + + assertEquals(expectedOptimizedPlan, new PushDownAndCombineFilters().apply(filterB)); + } + private static Completion completion(LogicalPlan child) { return new Completion( EMPTY, child, - randomLiteral(DataType.TEXT), - randomLiteral(DataType.TEXT), - referenceAttribute(randomIdentifier(), DataType.TEXT) + randomLiteral(DataType.KEYWORD), + randomLiteral(randomBoolean() ? DataType.TEXT : DataType.KEYWORD), + referenceAttribute(randomIdentifier(), DataType.KEYWORD) + ); + } + + private static Rerank rerank(LogicalPlan child) { + return new Rerank( + EMPTY, + child, + randomLiteral(DataType.KEYWORD), + randomLiteral(randomBoolean() ? DataType.TEXT : DataType.KEYWORD), + randomList(1, 10, () -> new Alias(EMPTY, randomIdentifier(), randomLiteral(randomFrom(DataType.values())))), + referenceAttribute(randomBoolean() ? MetadataAttribute.SCORE : randomIdentifier(), DataType.DOUBLE) ); } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineLimitsTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineLimitsTests.java index f5d88618b352d..c4c9e210c8e6e 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineLimitsTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineLimitsTests.java @@ -23,6 +23,7 @@ import org.elasticsearch.xpack.esql.plan.logical.OrderBy; import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan; import org.elasticsearch.xpack.esql.plan.logical.inference.Completion; +import org.elasticsearch.xpack.esql.plan.logical.inference.Rerank; import java.util.List; import java.util.function.BiConsumer; @@ -34,6 +35,7 @@ import static org.elasticsearch.xpack.esql.EsqlTestUtils.unboundLogicalOptimizerContext; import static org.elasticsearch.xpack.esql.core.tree.Source.EMPTY; import static org.elasticsearch.xpack.esql.core.type.DataType.INTEGER; +import static org.elasticsearch.xpack.esql.core.type.DataType.KEYWORD; import static org.elasticsearch.xpack.esql.core.type.DataType.TEXT; import static org.elasticsearch.xpack.esql.optimizer.LocalLogicalPlanOptimizerTests.relation; @@ -74,13 +76,31 @@ public void checkOptimizedPlan(LogicalPlan basePlan, LogicalPlan optimizedPlan) ), new PushDownLimitTestCase<>( Completion.class, - (plan, attr) -> new Completion(EMPTY, plan, randomLiteral(TEXT), randomLiteral(TEXT), attr), + (plan, attr) -> new Completion(EMPTY, plan, randomLiteral(KEYWORD), randomLiteral(KEYWORD), attr), (basePlan, optimizedPlan) -> { assertEquals(basePlan.source(), optimizedPlan.source()); assertEquals(basePlan.inferenceId(), optimizedPlan.inferenceId()); assertEquals(basePlan.prompt(), optimizedPlan.prompt()); assertEquals(basePlan.targetField(), optimizedPlan.targetField()); } + ), + new PushDownLimitTestCase<>( + Rerank.class, + (plan, attr) -> new Rerank( + EMPTY, + plan, + randomLiteral(KEYWORD), + randomLiteral(KEYWORD), + randomList(1, 10, () -> new Alias(EMPTY, randomIdentifier(), randomLiteral(KEYWORD))), + attr + ), + (basePlan, optimizedPlan) -> { + assertEquals(basePlan.source(), optimizedPlan.source()); + assertEquals(basePlan.inferenceId(), optimizedPlan.inferenceId()); + assertEquals(basePlan.queryText(), optimizedPlan.queryText()); + assertEquals(basePlan.rerankFields(), optimizedPlan.rerankFields()); + assertEquals(basePlan.scoreAttribute(), optimizedPlan.scoreAttribute()); + } ) ); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java index be7902b9840b9..581445f1d908c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java @@ -3342,13 +3342,74 @@ public void testPreserveParanthesis() { expectError("explain [row x = 1", "line 1:19: missing ']' at ''"); } - public void testRerankDefaultInferenceId() { + public void testRerankDefaultInferenceIdAndScoreAttribute() { assumeTrue("RERANK requires corresponding capability", EsqlCapabilities.Cap.RERANK.isEnabled()); var plan = processingCommand("RERANK \"query text\" ON title"); var rerank = as(plan, Rerank.class); assertThat(rerank.inferenceId(), equalTo(literalString(".rerank-v1-elasticsearch"))); + assertThat(rerank.scoreAttribute(), equalTo(attribute("_score"))); + assertThat(rerank.queryText(), equalTo(literalString("query text"))); + assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); + } + + public void testRerankInferenceId() { + assumeTrue("RERANK requires corresponding capability", EsqlCapabilities.Cap.RERANK.isEnabled()); + + var plan = processingCommand("RERANK \"query text\" ON title WITH inferenceId=inferenceId"); + var rerank = as(plan, Rerank.class); + + assertThat(rerank.inferenceId(), equalTo(literalString("inferenceId"))); + assertThat(rerank.queryText(), equalTo(literalString("query text"))); + assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); + assertThat(rerank.scoreAttribute(), equalTo(attribute("_score"))); + } + + public void testRerankQuotedInferenceId() { + assumeTrue("RERANK requires corresponding capability", EsqlCapabilities.Cap.RERANK.isEnabled()); + + var plan = processingCommand("RERANK \"query text\" ON title WITH inferenceId=\"inferenceId\""); + var rerank = as(plan, Rerank.class); + + assertThat(rerank.inferenceId(), equalTo(literalString("inferenceId"))); + assertThat(rerank.queryText(), equalTo(literalString("query text"))); + assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); + assertThat(rerank.scoreAttribute(), equalTo(attribute("_score"))); + } + + public void testRerankScoreAttribute() { + assumeTrue("RERANK requires corresponding capability", EsqlCapabilities.Cap.RERANK.isEnabled()); + + var plan = processingCommand("RERANK \"query text\" ON title WITH scoreColumn=rerank_score"); + var rerank = as(plan, Rerank.class); + + assertThat(rerank.inferenceId(), equalTo(literalString(".rerank-v1-elasticsearch"))); + assertThat(rerank.scoreAttribute(), equalTo(attribute("rerank_score"))); + assertThat(rerank.queryText(), equalTo(literalString("query text"))); + assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); + } + + public void testRerankQuotedScoreAttribute() { + assumeTrue("RERANK requires corresponding capability", EsqlCapabilities.Cap.RERANK.isEnabled()); + + var plan = processingCommand("RERANK \"query text\" ON title WITH scoreColumn=\"rerank_score\""); + var rerank = as(plan, Rerank.class); + + assertThat(rerank.inferenceId(), equalTo(literalString(".rerank-v1-elasticsearch"))); + assertThat(rerank.scoreAttribute(), equalTo(attribute("rerank_score"))); + assertThat(rerank.queryText(), equalTo(literalString("query text"))); + assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); + } + + public void testRerankInferenceIdAnddScoreAttribute() { + assumeTrue("RERANK requires corresponding capability", EsqlCapabilities.Cap.RERANK.isEnabled()); + + var plan = processingCommand("RERANK \"query text\" ON title WITH inferenceId=inferenceId, scoreColumn=rerank_score"); + var rerank = as(plan, Rerank.class); + + assertThat(rerank.inferenceId(), equalTo(literalString("inferenceId"))); + assertThat(rerank.scoreAttribute(), equalTo(attribute("rerank_score"))); assertThat(rerank.queryText(), equalTo(literalString("query text"))); assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); } @@ -3362,6 +3423,7 @@ public void testRerankSingleField() { assertThat(rerank.queryText(), equalTo(literalString("query text"))); assertThat(rerank.inferenceId(), equalTo(literalString("inferenceID"))); assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); + assertThat(rerank.scoreAttribute(), equalTo(attribute("_score"))); } public void testRerankMultipleFields() { @@ -3382,6 +3444,7 @@ public void testRerankMultipleFields() { ) ) ); + assertThat(rerank.scoreAttribute(), equalTo(attribute("_score"))); } public void testRerankComputedFields() { @@ -3403,25 +3466,41 @@ public void testRerankComputedFields() { ) ) ); + assertThat(rerank.scoreAttribute(), equalTo(attribute("_score"))); } public void testRerankWithPositionalParameters() { assumeTrue("RERANK requires corresponding capability", EsqlCapabilities.Cap.RERANK.isEnabled()); - var queryParams = new QueryParams(List.of(paramAsConstant(null, "query text"), paramAsConstant(null, "reranker"))); - var rerank = as(parser.createStatement("row a = 1 | RERANK ? ON title WITH inferenceId=?", queryParams), Rerank.class); + var queryParams = new QueryParams( + List.of(paramAsConstant(null, "query text"), paramAsConstant(null, "reranker"), paramAsConstant(null, "rerank_score")) + ); + var rerank = as( + parser.createStatement("row a = 1 | RERANK ? ON title WITH inferenceId=?, scoreColumn=? ", queryParams), + Rerank.class + ); assertThat(rerank.queryText(), equalTo(literalString("query text"))); assertThat(rerank.inferenceId(), equalTo(literalString("reranker"))); assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); + assertThat(rerank.scoreAttribute(), equalTo(attribute("rerank_score"))); } public void testRerankWithNamedParameters() { assumeTrue("RERANK requires corresponding capability", EsqlCapabilities.Cap.RERANK.isEnabled()); - var queryParams = new QueryParams(List.of(paramAsConstant("queryText", "query text"), paramAsConstant("inferenceId", "reranker"))); + var queryParams = new QueryParams( + List.of( + paramAsConstant("queryText", "query text"), + paramAsConstant("inferenceId", "reranker"), + paramAsConstant("scoreColumnName", "rerank_score") + ) + ); var rerank = as( - parser.createStatement("row a = 1 | RERANK ?queryText ON title WITH inferenceId=?inferenceId", queryParams), + parser.createStatement( + "row a = 1 | RERANK ?queryText ON title WITH inferenceId=?inferenceId, scoreColumn=?scoreColumnName", + queryParams + ), Rerank.class ); From 81e6fcac42ea3e72bd9ff51762e8cad83d02d191 Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 17 Jun 2025 12:19:59 +0200 Subject: [PATCH 05/10] Remove useless Builder introduced in the previous commit. --- .../xpack/esql/parser/LogicalPlanBuilder.java | 4 +- .../esql/plan/logical/inference/Rerank.java | 42 +++++-------------- 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java index 0432f7c6c81db..1bf4b1ce91c73 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java @@ -742,10 +742,10 @@ public PlanFactory visitRerankCommand(EsqlBaseParser.RerankCommandContext ctx) { ); } - return p -> visitRerankOptions(new Rerank.Builder(source, p, queryText, rerankFields), ctx.commandOptions()).build(); + return p -> visitRerankOptions(new Rerank(source, p, queryText, rerankFields), ctx.commandOptions()); } - private Rerank.Builder visitRerankOptions(Rerank.Builder rerankBuilder, EsqlBaseParser.CommandOptionsContext ctx) { + private Rerank visitRerankOptions(Rerank rerankBuilder, EsqlBaseParser.CommandOptionsContext ctx) { if (ctx == null) { return rerankBuilder; } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java index 3630993c39828..112613a0b386c 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java @@ -49,6 +49,17 @@ public class Rerank extends InferencePlan implements TelemetryAware { private final List rerankFields; private List lazyOutput; + public Rerank(Source source, LogicalPlan child, Expression queryText, List rerankFields) { + this( + source, + child, + new Literal(Source.EMPTY, DEFAULT_INFERENCE_ID, DataType.KEYWORD), + queryText, + rerankFields, + new UnresolvedAttribute(Source.EMPTY, MetadataAttribute.SCORE) + ); + } + public Rerank( Source source, LogicalPlan child, @@ -183,35 +194,4 @@ public List output() { } return lazyOutput; } - - public static class Builder { - - private final Source source; - private final LogicalPlan child; - private final Expression queryText; - private final List rerankFields; - private Expression inferenceId = new Literal(Source.EMPTY, Rerank.DEFAULT_INFERENCE_ID, DataType.KEYWORD); - private Attribute scoreAttribute = new UnresolvedAttribute(Source.EMPTY, MetadataAttribute.SCORE); - - public Builder(Source source, LogicalPlan child, Expression queryText, List rerankFields) { - this.source = source; - this.child = child; - this.queryText = queryText; - this.rerankFields = rerankFields; - } - - public Builder withInferenceId(Expression inferenceId) { - this.inferenceId = inferenceId; - return this; - } - - public Builder withScoreAttribute(Attribute scoreAttribute) { - this.scoreAttribute = scoreAttribute; - return this; - } - - public Rerank build() { - return new Rerank(source, child, inferenceId, queryText, rerankFields, scoreAttribute); - } - } } From 701a17ce70b793926a496e257726860535420c61 Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 17 Jun 2025 14:01:00 +0200 Subject: [PATCH 06/10] Restore some previously deleted code. --- .../xpack/esql/parser/LogicalPlanBuilder.java | 8 ++++--- .../esql/plan/logical/inference/Rerank.java | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java index 1bf4b1ce91c73..02afb8e30afbb 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java @@ -745,11 +745,13 @@ public PlanFactory visitRerankCommand(EsqlBaseParser.RerankCommandContext ctx) { return p -> visitRerankOptions(new Rerank(source, p, queryText, rerankFields), ctx.commandOptions()); } - private Rerank visitRerankOptions(Rerank rerankBuilder, EsqlBaseParser.CommandOptionsContext ctx) { + private Rerank visitRerankOptions(Rerank rerank, EsqlBaseParser.CommandOptionsContext ctx) { if (ctx == null) { - return rerankBuilder; + return rerank; } + Rerank.Builder rerankBuilder = new Rerank.Builder(rerank); + for (var option : ctx.commandOption()) { String optionName = visitIdentifier(option.identifier()); if (optionName.equals(Rerank.INFERENCE_ID_OPTION_NAME)) { @@ -765,7 +767,7 @@ private Rerank visitRerankOptions(Rerank rerankBuilder, EsqlBaseParser.CommandOp } } - return rerankBuilder; + return rerankBuilder.build(); } @Override diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java index 112613a0b386c..a76961b422d3b 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java @@ -194,4 +194,26 @@ public List output() { } return lazyOutput; } + + public static class Builder { + private Rerank rerank; + + public Builder(Rerank rerank) { + this.rerank = rerank; + } + + public Rerank build() { + return rerank; + } + + public Builder withInferenceId(Expression inferenceId) { + this.rerank = this.rerank.withInferenceId(inferenceId); + return this; + } + + public Builder withScoreAttribute(Attribute scoreAttribute) { + this.rerank = this.rerank.withScoreAttribute(scoreAttribute); + return this; + } + } } From f4adb6433b9b0340967fdaaa2e9f209a7c1e2152 Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 17 Jun 2025 17:42:53 +0200 Subject: [PATCH 07/10] Fix a failing test. --- .../optimizer/rules/logical/PushDownAndCombineFiltersTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineFiltersTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineFiltersTests.java index 474da5def3e7d..ca975e1e09954 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineFiltersTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineFiltersTests.java @@ -333,7 +333,7 @@ private static Rerank rerank(LogicalPlan child) { child, randomLiteral(DataType.KEYWORD), randomLiteral(randomBoolean() ? DataType.TEXT : DataType.KEYWORD), - randomList(1, 10, () -> new Alias(EMPTY, randomIdentifier(), randomLiteral(randomFrom(DataType.values())))), + randomList(1, 10, () -> new Alias(EMPTY, randomIdentifier(), randomLiteral(DataType.KEYWORD))), referenceAttribute(randomBoolean() ? MetadataAttribute.SCORE : randomIdentifier(), DataType.DOUBLE) ); } From 5e39eaaab391e4e838b8ade717c877135450bfd8 Mon Sep 17 00:00:00 2001 From: afoucret Date: Wed, 18 Jun 2025 16:26:03 +0200 Subject: [PATCH 08/10] Remove useless import --- .../org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java index f9d98667bb475..7ffa2bfd75260 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java @@ -20,7 +20,6 @@ import org.elasticsearch.dissect.DissectParser; import org.elasticsearch.index.IndexMode; import org.elasticsearch.index.mapper.IdFieldMapper; -import org.elasticsearch.logging.LogManager; import org.elasticsearch.transport.RemoteClusterAware; import org.elasticsearch.xpack.esql.VerificationException; import org.elasticsearch.xpack.esql.action.EsqlCapabilities; From d86d16bed79f344ff8a82e2179fde0ce668ab145 Mon Sep 17 00:00:00 2001 From: afoucret Date: Wed, 18 Jun 2025 16:36:01 +0200 Subject: [PATCH 09/10] Readability. --- .../xpack/esql/parser/LogicalPlanBuilder.java | 4 +++- .../xpack/esql/plan/logical/inference/Rerank.java | 1 - .../xpack/esql/planner/LocalExecutionPlanner.java | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java index 7ffa2bfd75260..1079342566499 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java @@ -790,7 +790,9 @@ private UnresolvedAttribute visitRerankScoreAttribute(String optionName, EsqlBas throw new ParsingException(source(ctx), "Parameter [{}] is null or undefined", optionName); } - Expression optionValue = ctx.identifier() != null ? Literal.keyword(source(ctx.identifier()), visitIdentifier(ctx.identifier())) : expression(ctx.constant()); + Expression optionValue = ctx.identifier() != null + ? Literal.keyword(source(ctx.identifier()), visitIdentifier(ctx.identifier())) + : expression(ctx.constant()); if (optionValue instanceof UnresolvedAttribute scoreAttribute) { return scoreAttribute; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java index 47148fdc9cd67..308bdccfc0a01 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/inference/Rerank.java @@ -24,7 +24,6 @@ import org.elasticsearch.xpack.esql.core.expression.UnresolvedAttribute; import org.elasticsearch.xpack.esql.core.tree.NodeInfo; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.core.type.DataType; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java index bb73eb163820c..07767cd4e5ba7 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java @@ -620,6 +620,13 @@ private PhysicalOperation planRerank(RerankExec rerank, LocalExecutionPlannerCon EvalOperator.ExpressionEvaluator.Factory rowEncoderFactory; if (rerank.rerankFields().size() > 1) { + // If there is more than one field used for reranking we are encoded the input in a YAML doc, using field names as key. + // The input value will looks like + // text_field: foo bar + // multivalue_text_field: + // - value 1 + // - value 2 + // integer_field: 132 Map rerankFieldsEvaluatorSuppliers = Maps .newLinkedHashMapWithExpectedSize(rerank.rerankFields().size()); From c8563f6567d2c05e0a1d8e3bd449e2c4505e6539 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Wed, 18 Jun 2025 14:46:59 +0000 Subject: [PATCH 10/10] [CI] Auto commit changes from spotless --- .../xpack/esql/planner/LocalExecutionPlanner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java index 07767cd4e5ba7..a92d2f439a0ea 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java @@ -624,8 +624,8 @@ private PhysicalOperation planRerank(RerankExec rerank, LocalExecutionPlannerCon // The input value will looks like // text_field: foo bar // multivalue_text_field: - // - value 1 - // - value 2 + // - value 1 + // - value 2 // integer_field: 132 Map rerankFieldsEvaluatorSuppliers = Maps .newLinkedHashMapWithExpectedSize(rerank.rerankFields().size());