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

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

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

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

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

f = A("f")
i = B("i")
d = C("d")
c = D("c")
n = E("n")
e = A("e")
m = B("m")

f.r = m
i.p = n
d.q = c
d.p = n
d.z = n
c.t = m
c.s = n
c.v = n
c.q = e
n.r = d
e.r = m
m.p = n
assert e.r.p.r.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

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

f = A("f")
i = B("i")
d = C("d")
c = D("c")
n = E("n")
e = A("e")
m = B("m")

f.r = m
i.p = n
d.q = c
d.p = n
d.z = n
c.t = m
c.s = n
c.v = n
c.q = e
n.r = d
e.r = m
m.p = n
assert e.r.p.r.z.r.txt == "d"