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

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

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

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

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

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

a.q = b
b.y = j
b.r = e
l.q = b
e.y = d
e.r = j
j.y = d
j.r = e
h.q = d
c.q = e
d.y = j
d.r = e
i.q = e
assert l.q.r.y.r.y.r.txt == "e"