title: String concatenation queries
body: <p>I have a list of characters, say x in number, denoted by <code>b[1], b[2], b[3] ... b[x]</code>. After <code>x</code>, </p>
  
  <ul>
  <li><p><code>b[x+1]</code> is the concatenation of <code>b[1],b[2].... b[x]</code> in that order. Similarly, </p></li>
  <li><p><code>b[x+2]</code> is the concatenation of <code>b[2],b[3]....b[x],b[x+1]</code>. </p></li>
  <li><p>So, basically, <code>b[n]</code> will be concatenation of last <code>x</code> terms of <code>b[i]</code>, taken left from right.</p></li>
  <li><p>Given parameters as <code>p</code> and <code>q</code> as queries, how can I find out which character among <code>b[1], b[2], b[3]..... b[x]</code> does the <code>q</code><sup>th</sup> character of <code>b[p]</code> corresponds to?</p></li>
  </ul>
  
  <p><strong>Note:</strong> <code>x</code> and <code>b[1], b[2], b[3]..... b[x]</code> is fixed for all queries.</p>
  
  <p>I tried brute-forcing but the string length increases exponentially for large x.(x&lt;=100).</p>
  
  <hr>
  
  <p><strong>Example:</strong> </p>
  
  <ul>
  <li><p>When <code>x=3</code>, </p>
  
  <pre><code>b[] = a, b, c, a b c, b c abc, c abc bcabc, abc bcabc cabcbcabc, //....  
  //Spaces for clarity, only commas separate array elements
  </code></pre></li>
  <li><p>So for a query where <code>p=7</code>, <code>q=5</code>, answer returned would be <code>3</code>(corresponding to character <code>'c'</code>).</p></li>
  </ul>
  
  <p>I am just having difficulty figuring out the maths behind it. Language is no issue</p>