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

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

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

b = A("b")
f = B("f")
c = C("c")
h = A("h")

b.u = c
f.q = b
c.y = f
c.z = f
c.v = b
h.u = c
assert h.u.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

b = A("b")
f = B("f")
c = C("c")
h = A("h")

b.u = c
f.q = b
c.y = f
c.z = f
c.v = b
h.u = c
assert h.u.v.u.txt == "c"