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

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

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

m = A("m")
j = B("j")
a = C("a")
f = B("f")

m.v = a
j.x = a
j.p = a
j.o = f
a.p = f
a.y = m
a.q = m
f.x = a
f.p = a
f.o = j
assert a.p.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

m = A("m")
j = B("j")
a = C("a")
f = B("f")

m.v = a
j.x = a
j.p = a
j.o = f
a.p = f
a.y = m
a.q = m
f.x = a
f.p = a
f.o = j
assert a.p.p.y.txt == "m"