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

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

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

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

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

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

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

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

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

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

f.x = n
f.y = e
c.z = k
c.v = k
c.s = k
c.p = d
n.o = e
n.s = f
n.w = m
i.o = c
b.x = d
b.y = k
m.x = n
m.y = k
e.o = c
k.o = c
d.o = k
d.s = f
d.w = f
assert b.y.o.p.w.txt == "f"