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

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

class C:
    def __init__(self, txt: str):
        self.s: E = 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.u: A = None
        self.p: B = None
        self.r: E = None
        self.txt = txt

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

d.q = n
d.r = g
d.s = h
c.v = j
h.s = n
m.q = h
n.u = a
n.p = c
n.r = g
a.q = n
a.r = g
a.s = h
j.v = c
g.u = a
g.p = j
g.r = n
assert c.v.v.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.r: E = None
        self.s: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: E = 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.u: A = None
        self.p: B = None
        self.r: E = None
        self.txt = txt

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

d.q = n
d.r = g
d.s = h
c.v = j
h.s = n
m.q = h
n.u = a
n.p = c
n.r = g
a.q = n
a.r = g
a.s = h
j.v = c
g.u = a
g.p = j
g.r = n
assert c.v.v.v.v.v.v.v.v.txt == "c"