Line-wrap into proper columns Input will be one or more space separated characters followed by a long string on STDIN or as an argument when called from the shell.

a C
WAtcIaElCpVqDRavOUejlgumcRCpfIWlaRFZpIoPYsWjsBSdlYfitfAPHpemiLpjaHheUGpFVQoZCnSCFgvpVzcoibdffoPRoJJwLIjVicPCdcvITXaQDjtMgrxQMZCkZNFmNqwGQYaSyPpdLOkAVHGVoVBiIksZCQHEaIxcRGwpIAmlChuhGEDajeJVXoCwFFuIvhEoqMuwrCDmZPcQxeaqJjynGWVjSaCCxWfupDbbEEFufDyealmbLxKfwlWCsSXwpPtuayxNVCodeEjeCIeHBYioeTogujuUFlWydOwInWGbsvlSwlwgfQaAmNTWPjsgqSCGzsJYfqGklpeLujFyrZJmNymUzpXLTkZcyPgPakAXTTfKlnnTCkjxxSZltwnLMOUCxlHOtLIUTqcbejXqyrwQgMaPUKcHBDZwMrCgwfVZUzxbdODBbBqEbpFLUOcPpVmsgLnfMXRWaddGnK



Your task is to line-wrap the string at a suitable length so that there is at least one column completely filled by each input character. All lines should be wrapped to the same length (except possibly the last one if it's shorter.)


In this case, the solution could be wrapping at 50 characters giving the output

WAtcIaElCpVqDRavOUejlgumcRCpfIWlaRFZpIoPYsWjsBSdlY
fitfAPHpemiLpjaHheUGpFVQoZCnSCFgvpVzcoibdffoPRoJJw
LIjVicPCdcvITXaQDjtMgrxQMZCkZNFmNqwGQYaSyPpdLOkAVH
GVoVBiIksZCQHEaIxcRGwpIAmlChuhGEDajeJVXoCwFFuIvhEo
qMuwrCDmZPcQxeaqJjynGWVjSaCCxWfupDbbEEFufDyealmbLx
KfwlWCsSXwpPtuayxNVCodeEjeCIeHBYioeTogujuUFlWydOwI
nWGbsvlSwlwgfQaAmNTWPjsgqSCGzsJYfqGklpeLujFyrZJmNy
mUzpXLTkZcyPgPakAXTTfKlnnTCkjxxSZltwnLMOUCxlHOtLIU
TqcbejXqyrwQgMaPUKcHBDZwMrCgwfVZUzxbdODBbBqEbpFLUO
cPpVmsgLnfMXRWaddGnK


The fifteenth (a) and twenty-seventh (C) all form a single column of the given input characters.
The last line may or may not be complete.


There can be more than one solutions. Any one of them can be considered valid.
Returning the string as-is is NOT allowed. (For those claiming that it forms one-row columns). The columns of the input characters must have at least two rows. You may assume that the input string is longer than 10 characters.
If there is no possible solution, your program must indicate this in some way(return status, printing "no solution", etc.) which you must mention.
Input will only include [a-zA-Z]


This is code-golf



Here's the actual program(python) that I use to generate these strings.

import random

a = 10
b = 50

s = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in xrange(a):
    c = ''
    for j in xrange(b):
        c += (random.choice(s))
    print c


I then rectangle-edit to get columns full of input characters and strip newlines, deleting random number of characters from the end of the last line.
GolfScript, 73 characters
n%(' '-:C;~:T,,1&gt;{T/zip{.,1&gt;*.&amp;.,1=*}%''*C&amp;C=},.{0=T/n*}{'no solution'}if

Breaks at the first position which is possible. The input must be given on STDIN in the format specified in the question.
Example (online):
X Y
abcdeXfYghijklmnXoYpqrstuvwXxYyzXYZ

abcdeXfYghi
jklmnXoYpqr
stuvwXxYyzX
YZ

Annotated code:
n%               # Split the input at newlines
(' '-:C;         # Extract the first line, remove all spaces
                 # and assign the resulting string to variable C
~:T              # Take the second line and assign this string
                 # to variable T
,,1&gt;             # Makes an array [1 2 3 ... L-1] where L is the 
                 # length of T
{                # A filter block {...}, selects all possible 
                 # line wrap positions from this array
  T/             #   Test the current length by splitting T (input)
                 #   in pieces
  zip            #   Transpose the result (i.e. we now have a array
                 #   of strings representing the columns)
  {              #   For each column
    .,1&gt;*        #     Is the length greater than one, then keep the column
                 #     else transforms it to the empty string (string * 0)
    .&amp;           #     &quot;and&quot;s the string with itself, i.e. the result
                 #     is a string of the distinct characters in the column
    .,1=*        #     If the length is 1 (i.e. only one character) keep
                 #     the column, otherwise reduce it to the empty string
  }%
  ''*            #   Combine the resulting characters into a string again
  C&amp;C=           #   Check if this string contails all characters from C
},
.{               # If the filter returns at least one possible wrap position
  0=             #   Take the first one
  T/n*           #   Split the string and join again with newlines
}{               # Else
  'no solution'  #   Return 'no solution'
}if              # Endif