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

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

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

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

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

m.v = n
i.o = c
i.x = m
i.v = m
i.w = f
n.u = c
n.t = d
n.p = f
n.r = f
d.w = c
d.s = m
f.u = i
f.t = d
f.p = n
f.r = n
c.o = i
c.x = m
c.v = m
c.w = n
assert d.w.x.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

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

m.v = n
i.o = c
i.x = m
i.v = m
i.w = f
n.u = c
n.t = d
n.p = f
n.r = f
d.w = c
d.s = m
f.u = i
f.t = d
f.p = n
f.r = n
c.o = i
c.x = m
c.v = m
c.w = n
assert d.w.x.v.u.txt == "c"