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

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: A = None
        self.y: C = None
        self.o: A = None
        self.txt = txt

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

h.s = f
h.z = i
n.x = f
f.q = h
f.s = i
i.v = f
i.y = f
i.r = h
i.o = h
j.x = f
assert n.x.q.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.z: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: A = None
        self.y: C = None
        self.o: A = None
        self.txt = txt

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

h.s = f
h.z = i
n.x = f
f.q = h
f.s = i
i.v = f
i.y = f
i.r = h
i.o = h
j.x = f
assert n.x.q.z.o.txt == "h"