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

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

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

j = A("j")
k = B("k")
a = C("a")
e = C("e")
f = B("f")
g = C("g")
h = B("h")

j.q = a
j.s = f
j.r = k
k.z = f
k.s = j
a.q = j
a.o = g
a.p = e
e.q = j
e.o = a
e.p = a
f.z = h
f.s = j
g.q = j
g.o = a
g.p = a
h.z = f
h.s = j
assert f.z.s.q.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.s: B = None
        self.r: B = None
        self.txt = txt

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

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

j = A("j")
k = B("k")
a = C("a")
e = C("e")
f = B("f")
g = C("g")
h = B("h")

j.q = a
j.s = f
j.r = k
k.z = f
k.s = j
a.q = j
a.o = g
a.p = e
e.q = j
e.o = a
e.p = a
f.z = h
f.s = j
g.q = j
g.o = a
g.p = a
h.z = f
h.s = j
assert f.z.s.q.p.o.txt == "a"