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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.z: C = None
        self.w: D = None
        self.v: D = None
        self.t: A = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.z: C = None
        self.w: D = None
        self.v: D = None
        self.t: A = None
        self.txt = txt

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

j.r = i
d.p = i
i.z = n
i.s = d
n.q = i
e.y = n
e.w = n
e.v = n
e.z = i
e.t = j
assert e.v.q.z.q.txt == "i"