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

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

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

a = A("a")
e = B("e")
k = C("k")
d = B("d")
h = A("h")
b = A("b")

a.p = k
a.s = k
e.q = b
e.u = d
e.s = k
k.o = e
k.w = b
d.q = a
d.u = e
d.s = k
h.p = k
h.s = k
b.p = k
b.s = k
assert b.s.o.q.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.s: C = None
        self.txt = txt

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

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

a = A("a")
e = B("e")
k = C("k")
d = B("d")
h = A("h")
b = A("b")

a.p = k
a.s = k
e.q = b
e.u = d
e.s = k
k.o = e
k.w = b
d.q = a
d.u = e
d.s = k
h.p = k
h.s = k
b.p = k
b.s = k
assert b.s.o.q.p.w.txt == "b"