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

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

k = A("k")
a = B("a")
c = B("c")
e = B("e")
l = B("l")
j = A("j")
h = A("h")
i = B("i")
d = A("d")

k.o = j
k.r = h
a.q = c
c.q = a
e.q = l
l.q = i
j.o = h
j.r = d
h.o = d
h.r = k
i.q = l
d.o = h
d.r = k
assert l.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: A = None
        self.txt = txt

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

k = A("k")
a = B("a")
c = B("c")
e = B("e")
l = B("l")
j = A("j")
h = A("h")
i = B("i")
d = A("d")

k.o = j
k.r = h
a.q = c
c.q = a
e.q = l
l.q = i
j.o = h
j.r = d
h.o = d
h.r = k
i.q = l
d.o = h
d.r = k
assert l.q.q.q.txt == "i"