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

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.v: A = 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.p: A = None
        self.txt = txt

d = A("d")
m = B("m")
f = C("f")
i = D("i")
h = E("h")

d.u = h
d.t = m
d.p = i
m.y = d
m.v = f
m.x = h
m.r = i
f.s = d
f.v = d
i.p = f
h.p = d
assert h.p.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.t: B = None
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.v: A = 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.p: A = None
        self.txt = txt

d = A("d")
m = B("m")
f = C("f")
i = D("i")
h = E("h")

d.u = h
d.t = m
d.p = i
m.y = d
m.v = f
m.x = h
m.r = i
f.s = d
f.v = d
i.p = f
h.p = d
assert h.p.t.r.txt == "i"