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

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

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

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

g.s = f
g.o = m
g.p = a
d.o = f
d.u = h
d.y = h
m.p = d
h.p = d
b.s = f
b.o = h
b.p = a
a.p = d
f.s = g
f.o = h
f.p = a
assert g.s.s.o.p.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.o: C = None
        self.p: C = None
        self.txt = txt

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

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

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

g.s = f
g.o = m
g.p = a
d.o = f
d.u = h
d.y = h
m.p = d
h.p = d
b.s = f
b.o = h
b.p = a
a.p = d
f.s = g
f.o = h
f.p = a
assert g.s.s.o.p.o.p.txt == "a"