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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.v: B = None
        self.s: B = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.v: B = None
        self.s: B = None
        self.txt = txt

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

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

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

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

e.q = d
e.z = n
e.r = k
c.p = k
c.v = n
c.s = n
g.z = k
g.y = e
d.v = c
d.r = e
i.q = k
k.q = d
k.z = c
k.r = e
m.z = e
m.y = k
n.p = e
n.v = c
n.s = c
assert n.p.r.r.q.txt == "d"