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

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

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

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

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

m.u = d
m.o = n
d.s = m
d.u = m
d.x = m
d.y = f
f.v = n
f.p = m
f.o = m
f.w = d
n.o = f
assert d.x.u.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.o: D = None
        self.txt = txt

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

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

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

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

m.u = d
m.o = n
d.s = m
d.u = m
d.x = m
d.y = f
f.v = n
f.p = m
f.o = m
f.w = d
n.o = f
assert d.x.u.y.p.txt == "m"