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

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

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

h = A("h")
g = B("g")
b = C("b")
k = A("k")

h.v = b
g.t = b
g.u = h
b.p = g
b.v = g
b.z = k
k.v = b
assert b.v.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

h = A("h")
g = B("g")
b = C("b")
k = A("k")

h.v = b
g.t = b
g.u = h
b.p = g
b.v = g
b.z = k
k.v = b
assert b.v.u.v.txt == "b"