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

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

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

f = A("f")
j = B("j")
c = C("c")
l = C("l")
n = B("n")
m = A("m")
h = B("h")
g = C("g")
k = C("k")
a = C("a")

f.u = m
f.r = k
f.z = g
j.r = n
c.t = m
c.x = g
l.t = f
l.x = a
n.r = j
m.u = f
m.r = c
m.z = a
h.r = j
g.t = f
g.x = k
k.t = f
k.x = a
a.t = m
a.x = k
assert h.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.r: C = None
        self.z: C = None
        self.txt = txt

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

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

f = A("f")
j = B("j")
c = C("c")
l = C("l")
n = B("n")
m = A("m")
h = B("h")
g = C("g")
k = C("k")
a = C("a")

f.u = m
f.r = k
f.z = g
j.r = n
c.t = m
c.x = g
l.t = f
l.x = a
n.r = j
m.u = f
m.r = c
m.z = a
h.r = j
g.t = f
g.x = k
k.t = f
k.x = a
a.t = m
a.x = k
assert h.r.r.r.r.r.r.txt == "n"