The quaint hamlet of Кодгольф in the Russian far east has a problem: their population is low (below 66), and no new people have arrived for years. Moreover, after centuries of near-isolation, just about everybody is related to each other.
Mayor Стекобмен has a solution that should keep the morale high: organise a wedding. However, the question is, are there two bachelors in the town that aren't at least cousins of each other?
The mayor fired up his state-of-the-art Microsoft Боб computer to consult the genealogy charts. They had just been updated to the brand-new ASCII format, and look like this:
ы┬К
ю
And this:
А┬д
О┴п┬Щ
Ф
And this:
з┬Й
Л┬м┴п─┬Ф
Ы┴я┬А ш┬Я
З Е
And even this:
ю┬────────Й
м┬Е
│ ш
│
│
Щ
Here's how it works. Each person is a letter from the Russian alphabet. Males are capital letters (any of АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ), females are lowercase letters (any of абвгдеёжзийклмнопрстуфхцчшщъыьэюя).
A '┬' between two people means they are married. Right below that is either another person - their child - or a '┴', meaning that this couple has two children; located to the left and right of the symbol.
Moreover, to the right and left of '┬' and '┴' there can be any number of '─' characters, to extend the lines, as it were. Similarly, there can be any number of '│' characters above a '┴' or below a '┬'.
Lastly, a character without any defined symbol above them is considered a new arrival to the village, and by definition unrelated to anybody.
Also be aware that this is a very conservative village. Nobody marries more than once, and every marriage is heterosexual. Furthermore, assume everybody in the graph is alive, and no two people share the same name: e.g., the same Cyrillic character never occurs more than once.
The two bachelors should be of the opposite gender, and they should not be first cousins or any more closely related. First cousins once removed is okay. In other words: they should not share a parent, or a grandparent, or have one's grandparent be another's parent.
Challenge
Make the shortest possible program with as input either a string (containing newline characters), or a string array, or a rectangular two-dimensional string or char array (no higher or wider than 100 characters), containing the family tree of the town. Assume the input is a valid family tree. Ignore any character not given an explicit function in the above description.
It's fine to use an encoding other than Unicode for input/output purposes, e.g. KOI8-R as long as it's known and standardised by someone other than yourself. Scoring is done per this answer. If your language handles Cyrillic natively, it's an advantage!
Return a boolean value of true or false (or a bit/int of 1 or 0, or any consistent truthy/falsey value used by the language of your choice) to indicate whether there can be a wedding given the family tree.
Examples
1.
ы┬К
ю
FALSE (there's only one bachelor)
2.
А┬д
ю┬О┴п┬Щ
Щ ф
FALSE (Щ and ф are cousins)
3.
з┬Й
Л┬м┴п─┬Ф
Ы┴я┬А ш┬Я
З Е
FALSE (З, Е and Ы are all male)
4.
з┬Й
Л┬м┴п─┬Ф
ё┴А┬я ш┬Я
З Е
TRUE (ё and Е can marry)
5.
ю┬────────Й
м┬Е
│ ш
│
│
Щ
TRUE (ш is not related to anybody)
6.
д┬Ф
ю┬────────Й┴─ё┬З
│ │
│ ш <this person smells bad
│
│
Щ <this person betrayed the Party!
FALSE (Щ and ш are cousins)
7.
Щ 1234567890 quick brown foxes jumped over the lazy dog ш
TRUE (Щ and ш are unrelated)
8.
з┬Й
Л┬м┴п─┬Ф
й┬Ы┴я┬А ш┬Я
Э З ю
TRUE (ю and З, and also ю and Э)
9.
А┬д ф┬Ж
м┴п┬Щ ю┬Я
Ф ц
TRUE (ц and Ф)
NOTE: Here is an ASCII version of roughly the same challenge.