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

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

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

d = A("d")
a = B("a")
g = C("g")
b = C("b")

d.s = b
d.x = g
d.o = g
a.p = d
g.v = d
g.p = d
g.r = b
b.v = d
b.p = d
b.r = g
assert b.v.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.x: C = None
        self.o: C = None
        self.txt = txt

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

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

d = A("d")
a = B("a")
g = C("g")
b = C("b")

d.s = b
d.x = g
d.o = g
a.p = d
g.v = d
g.p = d
g.r = b
b.v = d
b.p = d
b.r = g
assert b.v.o.v.txt == "d"