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

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

class C:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

l = A("l")
c = B("c")
e = C("e")
f = B("f")
b = B("b")
a = B("a")
m = A("m")
j = B("j")
g = C("g")
d = C("d")

l.q = m
l.t = m
c.y = m
e.w = g
f.y = m
b.y = m
a.y = l
m.q = l
m.t = l
j.y = m
g.w = e
d.w = e
assert j.y.q.q.q.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

l = A("l")
c = B("c")
e = C("e")
f = B("f")
b = B("b")
a = B("a")
m = A("m")
j = B("j")
g = C("g")
d = C("d")

l.q = m
l.t = m
c.y = m
e.w = g
f.y = m
b.y = m
a.y = l
m.q = l
m.t = l
j.y = m
g.w = e
d.w = e
assert j.y.q.q.q.t.t.t.txt == "m"