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

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

a = A("a")
h = B("h")
j = A("j")
e = A("e")
i = A("i")
f = A("f")
b = A("b")
k = A("k")
l = B("l")

a.q = k
a.r = h
h.p = l
j.q = e
j.r = h
e.q = j
e.r = l
i.q = e
i.r = h
f.q = k
f.r = l
b.q = i
b.r = l
k.q = a
k.r = h
l.p = h
assert h.p.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: B = None
        self.txt = txt

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

a = A("a")
h = B("h")
j = A("j")
e = A("e")
i = A("i")
f = A("f")
b = A("b")
k = A("k")
l = B("l")

a.q = k
a.r = h
h.p = l
j.q = e
j.r = h
e.q = j
e.r = l
i.q = e
i.r = h
f.q = k
f.r = l
b.q = i
b.r = l
k.q = a
k.r = h
l.p = h
assert h.p.p.p.p.p.p.p.p.txt == "h"