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

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

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

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

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

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

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

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

l.r = c
l.z = h
l.y = f
g.z = c
g.u = c
g.x = n
a.o = i
n.z = i
n.x = d
n.u = a
d.z = c
d.u = c
d.x = n
i.o = a
h.r = i
h.z = f
h.y = m
m.r = c
m.z = h
m.y = h
f.r = a
f.z = m
f.y = l
c.o = a
assert l.y.r.o.o.o.o.o.o.o.o.txt == "a"