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

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

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

a = A("a")
d = B("d")
c = C("c")

a.v = d
d.u = a
d.x = a
c.v = d
c.w = d
assert c.v.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

a = A("a")
d = B("d")
c = C("c")

a.v = d
d.u = a
d.x = a
c.v = d
c.w = d
assert c.v.u.v.txt == "d"