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

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

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

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

n = A("n")
d = B("d")
k = C("k")
m = D("m")

n.y = d
n.t = d
n.o = k
n.w = k
d.q = m
d.v = m
d.x = k
k.z = m
m.o = k
m.u = d
assert d.x.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: C = None
        self.w: C = None
        self.t: B = None
        self.txt = txt

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

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

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

n = A("n")
d = B("d")
k = C("k")
m = D("m")

n.y = d
n.t = d
n.o = k
n.w = k
d.q = m
d.v = m
d.x = k
k.z = m
m.o = k
m.u = d
assert d.x.z.o.txt == "k"