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

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

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

h = A("h")
k = B("k")
d = C("d")
l = A("l")
b = C("b")
n = B("n")
j = B("j")
i = C("i")

h.x = l
h.s = d
k.s = j
k.p = d
k.r = l
d.o = b
l.x = h
l.s = d
b.o = d
n.s = k
n.p = b
n.r = l
j.s = n
j.p = d
j.r = l
i.o = d
assert b.o.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: C = None
        self.txt = txt

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

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

h = A("h")
k = B("k")
d = C("d")
l = A("l")
b = C("b")
n = B("n")
j = B("j")
i = C("i")

h.x = l
h.s = d
k.s = j
k.p = d
k.r = l
d.o = b
l.x = h
l.s = d
b.o = d
n.s = k
n.p = b
n.r = l
j.s = n
j.p = d
j.r = l
i.o = d
assert b.o.o.o.o.o.o.o.o.txt == "b"