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

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

j = A("j")
f = B("f")
a = A("a")
b = A("b")
e = B("e")

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

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

j = A("j")
f = B("f")
a = A("a")
b = A("b")
e = B("e")

j.s = e
j.y = f
f.u = j
a.s = f
a.y = e
b.s = e
b.y = f
e.u = a
assert f.u.s.u.txt == "a"