{"trustable":false,"sections":[{"title":"","value":{"format":"MD","content":"\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n \"HTML-CSS\": {\n preferredFont: \"TeX\",\n availableFonts: [\"STIX\",\"TeX\"],\n linebreaks: { automatic:true },\n EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50)\n },\n ShowMathMenu: false,\n TeX: {\n extensions: [\"color.js\"],\n noUndefined: {\n attributes: {\n mathcolor: \"red\",\n mathbackground: \"#FFEEEE\",\n mathsize: \"90%\"\n }\n },\n Macros: { href: \"{}\" }\n },\n tex2jax: {\n inlineMath: [[\u0027$\u0027,\u0027$\u0027], [\u0027\\\\(\u0027,\u0027\\\\)\u0027]],\n displayMath: [ [\"$$\",\"$$\"], [\"\\\\[\", \"\\\\]\"] ],\n multiline: true,\n processEscapes: true\n },\n menuSettings: {\n context: \"Browser\"\n },\n messageStyle: \"none\"\n });\n \u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" src\u003d\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\"\u003e\u003c/script\u003e\n\u003ch3\u003e Read problems statements in \u003ca target\u003d\"_blank\" href\u003d\"https://www.codechef.com/download/translated/MARCH16/mandarin/STRPALIN.pdf\"\u003eMandarin Chinese\u003c/a\u003e, \u003ca target\u003d\"_blank\" href\u003d\"https://www.codechef.com/download/translated/MARCH16/russian/STRPALIN.pdf\"\u003eRussian\u003c/a\u003e and \u003ca target\u003d\"_blank\" href\u003d\"https://www.codechef.com/download/translated/MARCH16/vietnamese/STRPALIN.pdf\"\u003eVietnamese\u003c/a\u003e as well.\u003c/h3\u003e\n\n\n\u003cp\u003eChef likes strings a lot but he likes palindromic strings more. Today, Chef has two strings \u003cb\u003eA\u003c/b\u003e and \u003cb\u003eB\u003c/b\u003e, each consisting of lower case alphabets.\n\u003c/p\u003e\n\n\u003cp\u003e\nChef is eager to know whether it is possible to choose some \u003cb\u003enon empty\u003c/b\u003e strings \u003cb\u003es1\u003c/b\u003e and \u003cb\u003es2\u003c/b\u003e where \u003cb\u003es1\u003c/b\u003e is a substring of \u003cb\u003eA\u003c/b\u003e, \u003cb\u003es2\u003c/b\u003e is a substring of \u003cb\u003eB\u003c/b\u003e such that \u003cb\u003es1 + s2\u003c/b\u003e is a palindromic string. Here \u003cb\u003e\u0027+\u0027\u003c/b\u003e denotes the concatenation between the strings.\u003c/p\u003e\n\n\u003cp\u003e\u003cb\u003eNote:\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eA string is a palindromic string if it can be read same both forward as well as backward. To know more about palindromes click \u003ca href\u003d\"https://en.wikipedia.org/wiki/Palindrome\"\u003ehere\u003c/a\u003e.\u003c/p\u003e\n\n\u003ch3\u003eInput\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003eFirst line of input contains a single integer \u003cb\u003eT\u003c/b\u003e denoting the number of test cases.\u003c/li\u003e\n\u003cli\u003eFor each test case:\n\t\u003cul\u003e\n\t\t\u003cli\u003eFirst line contains the string \u003cb\u003eA\u003c/b\u003e\u003c/li\u003e\n\t\t\u003cli\u003eSecond line contains the string \u003cb\u003eB\u003c/b\u003e.\u003c/li\u003e\n\t\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ch3\u003eOutput\u003c/h3\u003e\n\u003cp\u003eFor each test case, Print \u003cb\u003e\"Yes\"\u003c/b\u003e (without quotes) if it possible to choose such strings \u003cb\u003es1 \u0026 s2\u003c/b\u003e. Print \u003cb\u003e\"No\"\u003c/b\u003e (without quotes) otherwise.\n\n\n\u003ch3\u003eConstraints\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003e\u003cb\u003e1 ≤ T ≤ 10 \u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003e1 ≤ |A|, |B| ≤ 1000 \u003c/b\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ch3\u003eSubtasks\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003e \u003cb\u003eSubtask 1:\u003c/b\u003e \u003cb\u003e1 ≤ |A|, |B| ≤ 10\u003c/b\u003e : ( 40 pts )\u003c/li\u003e\n\u003cli\u003e \u003cb\u003eSubtask 2:\u003c/b\u003e \u003cb\u003e1 ≤ |A|, |B| ≤ 1000\u003c/b\u003e : ( 60 pts )\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ch3\u003eExample\u003c/h3\u003e\n\u003cb\u003eInput\u003c/b\u003e\n\u003cpre\u003e\n3\nabc\nabc\na\nb\nabba\nbaab\n\n\u003c/pre\u003e\n\u003cb\u003eOutput\u003c/b\u003e\n\u003cpre\u003e\nYes\nNo\nYes\n\u003c/pre\u003e\n\n\u003ch3\u003eExplanation\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003e\u003cb\u003eTest 1:\u003c/b\u003e One possible way of choosing \u003cb\u003es1 \u0026 s2\u003c/b\u003e is \u003cb\u003es1 \u003d \"ab\"\u003c/b\u003e, \u003cb\u003es2 \u003d \"a\"\u003c/b\u003e such that \u003cb\u003es1 + s2\u003c/b\u003e i.e \u003cb\u003e\"aba\"\u003c/b\u003e is a palindrome.\u003c/li\u003e\n\u003cli\u003e\u003cb\u003eTest 2:\u003c/b\u003e There is no possible way to choose \u003cb\u003es1 \u0026 s2\u003c/b\u003e such that \u003cb\u003es1 + s2\u003c/b\u003e is a palindrome.\u003c/li\u003e\n\u003cli\u003e\u003cb\u003eTest 3:\u003c/b\u003e You can figure it out yourself.\u003c/li\u003e\n\u003c/ul\u003e\n\u003caside style\u003d\u0027background: #f8f8f8;padding: 10px 15px;\u0027\u003e\u003cdiv\u003e\u003c/div\u003e\u003c/aside\u003e"}},{"title":"","value":{"format":"MD","content":"*Demo Code*/\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass Palindrome\n{\npublic static void main(String args[]) throws java.lang.Exception\n{\nScanner sc\u003dnew Scanner(System.in);\nint T\u003dsc.nextInt();\nfor(int i\u003d0;i\u003cT;i++)\n{\nString A\u003dsc.next();\nString B\u003dsc.next();\nint temp\u003d1;\nfor(int j\u003d0;j\u003cA.length();j++)\n{\nif(B.contains(String.valueOf((A.charAt(j)))))\n{\ntemp\u003d0;\nSystem.out.println(\"Yes\");\nbreak;\n}\n}\nif(temp\u003d\u003d1)\n{\nSystem.out.println(\"No\");\n}\n}\n}\n}\n"}}]}