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

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

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

n = A("n")
d = B("d")
l = C("l")

n.s = l
d.u = n
d.v = l
l.y = n
assert n.s.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

n = A("n")
d = B("d")
l = C("l")

n.s = l
d.u = n
d.v = l
l.y = n
assert n.s.y.s.txt == "l"