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

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

h = A("h")
i = B("i")
c = B("c")
a = A("a")
l = A("l")
k = B("k")
b = B("b")
d = A("d")

h.x = d
h.o = c
i.s = c
c.s = i
a.x = l
a.o = i
l.x = a
l.o = c
k.s = i
b.s = i
d.x = a
d.o = k
assert h.x.x.x.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: B = None
        self.txt = txt

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

h = A("h")
i = B("i")
c = B("c")
a = A("a")
l = A("l")
k = B("k")
b = B("b")
d = A("d")

h.x = d
h.o = c
i.s = c
c.s = i
a.x = l
a.o = i
l.x = a
l.o = c
k.s = i
b.s = i
d.x = a
d.o = k
assert h.x.x.x.o.s.txt == "i"