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

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

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

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

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

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

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

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

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

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

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

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

d.r = j
h.s = j
h.v = l
a.r = m
f.p = j
f.z = d
f.q = n
f.r = n
i.p = n
i.t = n
i.y = m
i.s = a
m.p = n
m.s = n
m.t = n
m.y = i
n.r = m
l.p = a
l.s = a
l.t = a
l.y = m
j.r = d
c.p = d
c.z = d
c.q = n
c.r = n
assert d.r.r.r.r.r.txt == "j"