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

class B:
    def __init__(self, txt: str):
        self.t: E = None
        self.v: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: B = None
        self.p: A = None
        self.r: A = None
        self.txt = txt

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

d.q = j
d.v = j
d.r = b
b.t = j
b.v = d
m.v = d
m.w = d
m.r = e
e.r = d
j.x = e
j.q = b
j.p = d
j.r = d
assert m.w.r.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.v: E = None
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: E = None
        self.v: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: B = None
        self.p: A = None
        self.r: A = None
        self.txt = txt

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

d.q = j
d.v = j
d.r = b
b.t = j
b.v = d
m.v = d
m.w = d
m.r = e
e.r = d
j.x = e
j.q = b
j.p = d
j.r = d
assert m.w.r.t.x.txt == "e"