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

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

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

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

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

k.t = f
k.y = i
k.s = i
k.z = m
f.t = i
f.x = i
f.w = b
f.o = n
i.p = f
i.x = k
i.z = n
i.s = b
n.z = f
n.y = b
n.u = i
b.t = i
b.x = i
b.w = f
b.o = m
m.z = f
m.y = f
m.u = i
assert m.z.t.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.y: C = None
        self.z: D = None
        self.s: C = None
        self.txt = txt

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

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

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

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

k.t = f
k.y = i
k.s = i
k.z = m
f.t = i
f.x = i
f.w = b
f.o = n
i.p = f
i.x = k
i.z = n
i.s = b
n.z = f
n.y = b
n.u = i
b.t = i
b.x = i
b.w = f
b.o = m
m.z = f
m.y = f
m.u = i
assert m.z.t.s.w.txt == "f"