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

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

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

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

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

n = A("n")
b = B("b")
m = C("m")
j = D("j")
f = E("f")

n.r = b
n.x = f
b.y = j
b.t = n
b.q = f
m.v = b
m.z = f
j.p = m
f.r = j
f.s = b
assert n.x.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: E = None
        self.txt = txt

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

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

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

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

n = A("n")
b = B("b")
m = C("m")
j = D("j")
f = E("f")

n.r = b
n.x = f
b.y = j
b.t = n
b.q = f
m.v = b
m.z = f
j.p = m
f.r = j
f.s = b
assert n.x.s.t.txt == "n"