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

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

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

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

g = A("g")
i = B("i")
k = C("k")
e = D("e")
m = D("m")
a = A("a")

g.t = a
i.t = k
i.x = k
i.z = k
i.o = a
k.z = g
k.t = a
e.s = g
m.s = a
a.t = g
assert i.o.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

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

g = A("g")
i = B("i")
k = C("k")
e = D("e")
m = D("m")
a = A("a")

g.t = a
i.t = k
i.x = k
i.z = k
i.o = a
k.z = g
k.t = a
e.s = g
m.s = a
a.t = g
assert i.o.t.t.t.t.t.txt == "g"