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

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.x: A = None
        self.txt = txt

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

j = A("j")
h = B("h")
m = C("m")
k = B("k")
d = A("d")
n = C("n")
c = B("c")
e = A("e")
a = A("a")
g = C("g")

j.q = c
j.r = n
j.u = d
h.q = m
h.x = a
m.r = j
m.y = j
m.x = k
k.q = n
k.x = e
d.q = c
d.r = m
d.u = e
n.r = d
n.x = k
n.y = j
c.q = n
c.x = a
e.q = h
e.r = n
e.u = d
a.q = k
a.r = g
a.u = j
g.r = a
g.x = k
g.y = j
assert k.x.u.r.r.r.y.r.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: C = None
        self.u: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.x: A = None
        self.txt = txt

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

j = A("j")
h = B("h")
m = C("m")
k = B("k")
d = A("d")
n = C("n")
c = B("c")
e = A("e")
a = A("a")
g = C("g")

j.q = c
j.r = n
j.u = d
h.q = m
h.x = a
m.r = j
m.y = j
m.x = k
k.q = n
k.x = e
d.q = c
d.r = m
d.u = e
n.r = d
n.x = k
n.y = j
c.q = n
c.x = a
e.q = h
e.r = n
e.u = d
a.q = k
a.r = g
a.u = j
g.r = a
g.x = k
g.y = j
assert k.x.u.r.r.r.y.r.x.x.txt == "e"