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

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

k = A("k")
d = B("d")
j = A("j")
f = B("f")
h = B("h")
a = B("a")

k.o = a
d.s = f
j.o = d
f.s = h
h.s = a
a.s = f
assert k.o.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

k = A("k")
d = B("d")
j = A("j")
f = B("f")
h = B("h")
a = B("a")

k.o = a
d.s = f
j.o = d
f.s = h
h.s = a
a.s = f
assert k.o.s.s.s.s.s.txt == "h"