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

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

i = A("i")
b = B("b")
k = B("k")
f = A("f")
n = A("n")
a = A("a")

i.u = n
i.o = b
b.s = n
k.s = f
f.u = i
f.o = b
n.u = a
n.o = k
a.u = i
a.o = b
assert f.u.u.o.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: B = None
        self.txt = txt

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

i = A("i")
b = B("b")
k = B("k")
f = A("f")
n = A("n")
a = A("a")

i.u = n
i.o = b
b.s = n
k.s = f
f.u = i
f.o = b
n.u = a
n.o = k
a.u = i
a.o = b
assert f.u.u.o.s.u.txt == "i"