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

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

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

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

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

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

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

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

g.p = i
g.v = i
g.o = d
b.s = i
b.o = d
b.r = a
i.p = a
i.q = d
i.v = b
m.s = i
m.o = d
m.r = a
a.s = i
a.o = d
a.r = b
d.p = i
d.v = i
d.o = g
assert a.r.o.o.p.p.txt == "a"