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

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

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

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

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

a = A("a")
n = B("n")
k = C("k")
c = D("c")
i = E("i")
h = A("h")
f = B("f")

a.y = c
a.x = k
a.p = h
a.r = h
n.t = i
k.t = n
c.w = k
c.z = k
c.u = k
c.q = k
i.p = c
i.z = k
i.r = k
i.q = k
h.y = c
h.x = k
h.p = a
h.r = a
f.t = i
assert i.q.t.t.r.t.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.x: C = None
        self.p: A = None
        self.r: A = None
        self.txt = txt

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

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

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

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

a = A("a")
n = B("n")
k = C("k")
c = D("c")
i = E("i")
h = A("h")
f = B("f")

a.y = c
a.x = k
a.p = h
a.r = h
n.t = i
k.t = n
c.w = k
c.z = k
c.u = k
c.q = k
i.p = c
i.z = k
i.r = k
i.q = k
h.y = c
h.x = k
h.p = a
h.r = a
f.t = i
assert i.q.t.t.r.t.t.q.txt == "k"