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

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

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

j = A("j")
l = B("l")
e = C("e")
b = A("b")
h = C("h")
f = B("f")
a = A("a")
g = B("g")

j.t = e
l.w = a
l.u = h
e.x = j
b.t = h
h.x = j
f.w = b
f.u = h
a.t = e
g.w = j
g.u = h
assert h.x.t.x.t.x.t.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

j = A("j")
l = B("l")
e = C("e")
b = A("b")
h = C("h")
f = B("f")
a = A("a")
g = B("g")

j.t = e
l.w = a
l.u = h
e.x = j
b.t = h
h.x = j
f.w = b
f.u = h
a.t = e
g.w = j
g.u = h
assert h.x.t.x.t.x.t.x.t.txt == "e"