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

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

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

a = A("a")
h = B("h")
n = C("n")
g = A("g")
i = A("i")
k = B("k")
c = C("c")
d = A("d")
f = C("f")
e = B("e")

a.r = f
h.u = k
h.t = i
h.q = f
n.x = c
n.u = c
n.w = h
g.r = n
i.r = n
k.u = h
k.t = g
k.q = c
c.x = f
c.w = h
c.u = n
d.r = c
f.x = n
f.w = h
f.u = c
e.u = h
e.t = i
e.q = f
assert i.r.u.x.u.x.w.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

a = A("a")
h = B("h")
n = C("n")
g = A("g")
i = A("i")
k = B("k")
c = C("c")
d = A("d")
f = C("f")
e = B("e")

a.r = f
h.u = k
h.t = i
h.q = f
n.x = c
n.u = c
n.w = h
g.r = n
i.r = n
k.u = h
k.t = g
k.q = c
c.x = f
c.w = h
c.u = n
d.r = c
f.x = n
f.w = h
f.u = c
e.u = h
e.t = i
e.q = f
assert i.r.u.x.u.x.w.q.u.txt == "c"