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

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

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

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

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

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

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

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

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

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

f.r = n
f.w = m
f.v = m
f.y = i
i.o = m
n.v = m
m.x = d
m.o = d
m.u = n
m.w = n
d.x = m
d.o = m
d.u = n
d.w = n
assert f.w.x.x.w.v.txt == "m"