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

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.x: A = None
        self.t: E = None
        self.v: C = None
        self.z: A = None
        self.txt = txt

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

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

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

a = A("a")
f = B("f")
b = C("b")
m = D("m")
h = E("h")

a.p = h
f.s = m
f.x = a
f.z = a
f.t = h
f.v = b
b.u = a
m.s = f
m.z = a
m.v = a
h.r = b
assert a.p.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.x: A = None
        self.t: E = None
        self.v: C = None
        self.z: A = None
        self.txt = txt

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

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

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

a = A("a")
f = B("f")
b = C("b")
m = D("m")
h = E("h")

a.p = h
f.s = m
f.x = a
f.z = a
f.t = h
f.v = b
b.u = a
m.s = f
m.z = a
m.v = a
h.r = b
assert a.p.r.u.txt == "a"