class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

k = A("k")
l = B("l")
j = A("j")
n = A("n")
c = B("c")
a = A("a")
b = A("b")
g = A("g")
h = A("h")

k.q = l
k.r = c
l.o = c
j.q = l
j.r = c
n.q = c
n.r = c
c.o = l
a.q = c
a.r = l
b.q = l
b.r = c
g.q = l
g.r = c
h.q = l
h.r = l
assert l.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

k = A("k")
l = B("l")
j = A("j")
n = A("n")
c = B("c")
a = A("a")
b = A("b")
g = A("g")
h = A("h")

k.q = l
k.r = c
l.o = c
j.q = l
j.r = c
n.q = c
n.r = c
c.o = l
a.q = c
a.r = l
b.q = l
b.r = c
g.q = l
g.r = c
h.q = l
h.r = l
assert l.o.o.o.o.o.o.o.txt == "c"