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

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

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

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

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

h = A("h")
d = B("d")
i = C("i")
b = D("b")
n = E("n")

h.p = i
d.r = n
d.q = n
d.y = h
i.y = b
i.q = b
i.z = n
i.u = d
b.s = d
b.z = n
b.v = n
b.t = i
n.q = i
assert i.u.q.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

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

h = A("h")
d = B("d")
i = C("i")
b = D("b")
n = E("n")

h.p = i
d.r = n
d.q = n
d.y = h
i.y = b
i.q = b
i.z = n
i.u = d
b.s = d
b.z = n
b.v = n
b.t = i
n.q = i
assert i.u.q.q.u.txt == "d"