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

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

f = A("f")
n = B("n")
e = A("e")
d = B("d")

f.y = d
n.u = f
e.y = d
d.u = e
assert n.u.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

f = A("f")
n = B("n")
e = A("e")
d = B("d")

f.y = d
n.u = f
e.y = d
d.u = e
assert n.u.y.u.txt == "e"