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

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

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

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

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

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

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

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

b.t = k
g.s = f
k.o = f
k.x = g
h.o = n
h.x = g
d.t = k
f.t = h
e.t = k
c.t = h
n.t = h
assert c.t.x.s.t.o.t.o.txt == "n"