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

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

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

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

i = A("i")
n = B("n")
f = C("f")
h = D("h")

i.t = f
i.p = f
i.q = f
i.o = n
n.v = f
n.o = i
n.u = i
f.z = i
f.u = i
f.x = i
h.x = f
h.t = f
assert h.x.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: C = None
        self.o: B = None
        self.q: C = None
        self.txt = txt

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

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

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

i = A("i")
n = B("n")
f = C("f")
h = D("h")

i.t = f
i.p = f
i.q = f
i.o = n
n.v = f
n.o = i
n.u = i
f.z = i
f.u = i
f.x = i
h.x = f
h.t = f
assert h.x.z.o.txt == "n"