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

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

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

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

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

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

h.p = b
h.q = b
h.z = c
b.s = h
b.w = h
b.t = h
b.o = i
b.x = c
c.p = d
d.q = i
d.y = b
d.t = h
i.u = d
assert b.x.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: C = None
        self.q: B = None
        self.txt = txt

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

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

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

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

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

h.p = b
h.q = b
h.z = c
b.s = h
b.w = h
b.t = h
b.o = i
b.x = c
c.p = d
d.q = i
d.y = b
d.t = h
i.u = d
assert b.x.p.y.txt == "b"