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

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

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

g = A("g")
a = B("a")
n = C("n")
e = B("e")
c = A("c")
h = B("h")
k = C("k")
b = B("b")
l = A("l")
f = A("f")

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

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

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

g = A("g")
a = B("a")
n = C("n")
e = B("e")
c = A("c")
h = B("h")
k = C("k")
b = B("b")
l = A("l")
f = A("f")

g.t = k
a.x = g
a.w = f
n.x = c
e.x = g
e.w = l
c.t = k
h.x = g
h.w = g
k.x = l
b.x = f
b.w = f
l.t = k
f.t = n
assert h.w.t.x.t.x.txt == "l"