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

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

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

j = A("j")
n = B("n")
i = C("i")
g = B("g")
d = C("d")

j.o = n
n.z = i
n.v = g
n.p = g
i.q = n
i.x = n
i.s = g
g.z = d
g.v = n
g.p = n
d.q = n
d.s = g
d.x = g
assert i.s.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

j = A("j")
n = B("n")
i = C("i")
g = B("g")
d = C("d")

j.o = n
n.z = i
n.v = g
n.p = g
i.q = n
i.x = n
i.s = g
g.z = d
g.v = n
g.p = n
d.q = n
d.s = g
d.x = g
assert i.s.p.z.txt == "i"