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

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

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

b = A("b")
n = B("n")
h = C("h")
l = A("l")

b.o = n
b.z = l
n.v = b
h.v = n
h.t = n
h.q = l
l.o = n
l.z = b
assert n.v.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: A = None
        self.txt = txt

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

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

b = A("b")
n = B("n")
h = C("h")
l = A("l")

b.o = n
b.z = l
n.v = b
h.v = n
h.t = n
h.q = l
l.o = n
l.z = b
assert n.v.z.o.txt == "n"