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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.q: B = None
        self.txt = txt

b = A("b")
j = B("j")
c = C("c")
a = D("a")
f = E("f")

b.t = j
b.v = a
j.x = f
j.q = c
j.w = c
j.p = b
c.z = b
a.p = c
a.s = c
a.z = c
a.t = j
f.y = a
f.q = j
assert a.p.z.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.q: B = None
        self.txt = txt

b = A("b")
j = B("j")
c = C("c")
a = D("a")
f = E("f")

b.t = j
b.v = a
j.x = f
j.q = c
j.w = c
j.p = b
c.z = b
a.p = c
a.s = c
a.z = c
a.t = j
f.y = a
f.q = j
assert a.p.z.t.p.txt == "b"