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

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

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

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

d.v = a
d.p = a
d.y = e
e.t = d
e.r = a
a.q = d
a.o = d
assert d.v.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.p: C = None
        self.y: B = None
        self.txt = txt

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

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

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

d.v = a
d.p = a
d.y = e
e.t = d
e.r = a
a.q = d
a.o = d
assert d.v.o.y.txt == "e"