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

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

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

b = A("b")
k = B("k")
m = C("m")
h = A("h")
g = B("g")
a = C("a")
i = C("i")
n = A("n")
j = A("j")

b.o = h
k.r = n
m.y = a
m.p = g
m.u = k
h.o = n
g.r = h
a.y = i
a.p = k
a.u = k
i.y = a
i.p = k
i.u = g
n.o = b
j.o = b
assert b.o.o.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

b = A("b")
k = B("k")
m = C("m")
h = A("h")
g = B("g")
a = C("a")
i = C("i")
n = A("n")
j = A("j")

b.o = h
k.r = n
m.y = a
m.p = g
m.u = k
h.o = n
g.r = h
a.y = i
a.p = k
a.u = k
i.y = a
i.p = k
i.u = g
n.o = b
j.o = b
assert b.o.o.o.o.o.o.o.o.o.txt == "b"