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

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

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

c = A("c")
e = B("e")
h = C("h")
g = B("g")
a = A("a")
i = C("i")
j = A("j")
k = B("k")
l = C("l")
n = A("n")

c.t = i
e.t = c
h.t = a
h.w = k
g.t = c
a.t = l
i.t = n
i.w = e
j.t = h
k.t = j
l.t = a
l.w = e
n.t = h
assert j.t.t.t.w.t.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

c = A("c")
e = B("e")
h = C("h")
g = B("g")
a = A("a")
i = C("i")
j = A("j")
k = B("k")
l = C("l")
n = A("n")

c.t = i
e.t = c
h.t = a
h.w = k
g.t = c
a.t = l
i.t = n
i.w = e
j.t = h
k.t = j
l.t = a
l.w = e
n.t = h
assert j.t.t.t.w.t.t.w.txt == "e"