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

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: A = None
        self.v: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.s: A = None
        self.y: A = None
        self.p: D = None
        self.txt = txt

a = A("a")
n = B("n")
d = C("d")
k = D("k")
i = E("i")
j = E("j")

a.q = n
a.r = i
n.z = a
n.x = a
n.v = i
d.u = a
d.v = a
k.p = j
k.z = a
i.s = a
i.y = a
i.p = k
j.s = a
j.y = a
j.p = k
assert a.r.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: A = None
        self.v: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.s: A = None
        self.y: A = None
        self.p: D = None
        self.txt = txt

a = A("a")
n = B("n")
d = C("d")
k = D("k")
i = E("i")
j = E("j")

a.q = n
a.r = i
n.z = a
n.x = a
n.v = i
d.u = a
d.v = a
k.p = j
k.z = a
i.s = a
i.y = a
i.p = k
j.s = a
j.y = a
j.p = k
assert a.r.s.r.txt == "i"