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

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

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

h = A("h")
a = B("a")
i = C("i")
e = A("e")
b = C("b")
f = C("f")
k = A("k")
c = B("c")

h.r = k
a.o = h
a.u = c
a.z = k
i.u = f
i.w = f
e.r = h
b.u = f
b.w = i
f.u = b
f.w = i
k.r = h
c.o = e
c.u = a
c.z = k
assert a.o.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

h = A("h")
a = B("a")
i = C("i")
e = A("e")
b = C("b")
f = C("f")
k = A("k")
c = B("c")

h.r = k
a.o = h
a.u = c
a.z = k
i.u = f
i.w = f
e.r = h
b.u = f
b.w = i
f.u = b
f.w = i
k.r = h
c.o = e
c.u = a
c.z = k
assert a.o.r.r.r.r.r.r.txt == "h"