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

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

d = A("d")
j = B("j")
m = C("m")
e = D("e")
h = E("h")
f = E("f")

d.q = j
d.v = e
d.r = e
d.z = m
j.v = m
m.q = j
e.p = d
e.q = m
h.s = j
f.s = j
assert d.q.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: D = None
        self.r: D = None
        self.z: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

d = A("d")
j = B("j")
m = C("m")
e = D("e")
h = E("h")
f = E("f")

d.q = j
d.v = e
d.r = e
d.z = m
j.v = m
m.q = j
e.p = d
e.q = m
h.s = j
f.s = j
assert d.q.v.q.txt == "j"