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

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

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

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

d.v = n
d.o = n
n.t = k
k.q = n
k.o = d
assert d.v.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: B = None
        self.txt = txt

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

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

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

d.v = n
d.o = n
n.t = k
k.q = n
k.o = d
assert d.v.t.o.txt == "d"