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

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

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

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

a = A("a")
f = B("f")
n = C("n")
m = D("m")
i = A("i")

a.s = n
a.t = n
a.o = n
a.x = n
f.t = m
n.z = a
m.p = n
m.x = n
i.s = n
i.t = n
i.o = n
i.x = n
assert n.z.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: C = None
        self.o: C = None
        self.x: C = None
        self.txt = txt

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

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

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

a = A("a")
f = B("f")
n = C("n")
m = D("m")
i = A("i")

a.s = n
a.t = n
a.o = n
a.x = n
f.t = m
n.z = a
m.p = n
m.x = n
i.s = n
i.t = n
i.o = n
i.x = n
assert n.z.x.z.txt == "a"