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

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

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

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

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

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

a.p = j
a.u = j
j.t = b
j.x = a
j.r = e
b.y = m
b.r = e
e.v = b
m.w = a
m.z = b
i.t = b
i.x = a
i.r = e
assert j.r.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: B = None
        self.txt = txt

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

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

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

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

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

a.p = j
a.u = j
j.t = b
j.x = a
j.r = e
b.y = m
b.r = e
e.v = b
m.w = a
m.z = b
i.t = b
i.x = a
i.r = e
assert j.r.v.r.txt == "e"