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

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

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

g = A("g")
c = B("c")
n = C("n")

g.r = n
c.p = g
c.v = g
c.r = n
n.o = c
assert c.v.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

g = A("g")
c = B("c")
n = C("n")

g.r = n
c.p = g
c.v = g
c.r = n
n.o = c
assert c.v.r.o.txt == "c"