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

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

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

a = A("a")
g = B("g")
i = C("i")
c = B("c")
b = C("b")
j = B("j")
k = C("k")
m = B("m")
h = C("h")
e = A("e")

a.y = k
g.t = e
g.y = j
i.u = c
c.t = a
c.y = m
b.u = j
j.t = e
j.y = m
k.u = m
m.t = e
m.y = g
h.u = m
e.y = b
assert m.t.y.u.y.y.y.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

a = A("a")
g = B("g")
i = C("i")
c = B("c")
b = C("b")
j = B("j")
k = C("k")
m = B("m")
h = C("h")
e = A("e")

a.y = k
g.t = e
g.y = j
i.u = c
c.t = a
c.y = m
b.u = j
j.t = e
j.y = m
k.u = m
m.t = e
m.y = g
h.u = m
e.y = b
assert m.t.y.u.y.y.y.t.y.txt == "b"