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.o: A = None
        self.txt = txt

f = A("f")
l = B("l")
n = B("n")
k = A("k")
c = A("c")
i = A("i")
j = B("j")
a = B("a")

f.u = i
f.o = j
l.o = f
n.o = i
k.u = i
k.o = l
c.u = f
c.o = a
i.u = k
i.o = l
j.o = k
a.o = c
assert f.u.u.o.o.u.o.o.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.o: A = None
        self.txt = txt

f = A("f")
l = B("l")
n = B("n")
k = A("k")
c = A("c")
i = A("i")
j = B("j")
a = B("a")

f.u = i
f.o = j
l.o = f
n.o = i
k.u = i
k.o = l
c.u = f
c.o = a
i.u = k
i.o = l
j.o = k
a.o = c
assert f.u.u.o.o.u.o.o.txt == "f"