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

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

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

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

m = A("m")
f = B("f")
d = C("d")
a = D("a")
e = B("e")

m.q = a
m.o = a
m.p = d
f.p = m
f.w = m
f.x = m
d.r = e
d.v = a
a.p = d
e.p = m
e.w = m
e.x = m
assert d.v.p.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.p: C = None
        self.o: D = None
        self.txt = txt

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

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

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

m = A("m")
f = B("f")
d = C("d")
a = D("a")
e = B("e")

m.q = a
m.o = a
m.p = d
f.p = m
f.w = m
f.x = m
d.r = e
d.v = a
a.p = d
e.p = m
e.w = m
e.x = m
assert d.v.p.r.x.txt == "m"