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

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

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

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

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

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

a.s = b
n.u = b
e.u = b
d.u = a
f.u = a
b.s = a
assert d.u.s.s.txt == "a"