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

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

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

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

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

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

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

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

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

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

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

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

c.r = n
l.y = g
i.v = c
a.z = c
a.t = c
a.p = c
a.r = h
a.q = l
g.u = c
g.v = a
f.v = c
h.y = g
n.v = c
assert n.v.r.v.r.v.r.txt == "n"