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

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

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

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

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

d = A("d")
h = B("h")
f = C("f")
i = D("i")
k = E("k")
c = E("c")
e = B("e")
j = A("j")

d.p = k
d.z = j
d.w = f
d.q = h
h.r = i
f.p = e
i.s = h
i.u = c
k.z = i
c.z = i
e.r = i
j.p = c
j.z = d
j.w = f
j.q = e
assert i.s.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.z: A = None
        self.w: C = None
        self.q: B = None
        self.txt = txt

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

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

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

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

d = A("d")
h = B("h")
f = C("f")
i = D("i")
k = E("k")
c = E("c")
e = B("e")
j = A("j")

d.p = k
d.z = j
d.w = f
d.q = h
h.r = i
f.p = e
i.s = h
i.u = c
k.z = i
c.z = i
e.r = i
j.p = c
j.z = d
j.w = f
j.q = e
assert i.s.r.u.txt == "c"