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

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

f = A("f")
l = B("l")
e = B("e")
j = B("j")
n = B("n")
b = A("b")
k = A("k")
a = B("a")

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

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

f = A("f")
l = B("l")
e = B("e")
j = B("j")
n = B("n")
b = A("b")
k = A("k")
a = B("a")

f.y = b
f.o = e
l.u = b
e.u = k
j.u = f
n.u = f
b.y = f
b.o = l
k.y = b
k.o = e
a.u = b
assert f.o.u.o.u.o.txt == "e"