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

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

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

l = A("l")
b = B("b")
h = C("h")
a = C("a")
g = C("g")
i = B("i")
f = A("f")
n = A("n")

l.s = n
b.o = i
h.x = i
a.x = i
g.x = b
i.o = b
f.s = n
n.s = l
assert h.x.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

l = A("l")
b = B("b")
h = C("h")
a = C("a")
g = C("g")
i = B("i")
f = A("f")
n = A("n")

l.s = n
b.o = i
h.x = i
a.x = i
g.x = b
i.o = b
f.s = n
n.s = l
assert h.x.o.o.o.o.txt == "i"