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

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

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

c = A("c")
b = B("b")
j = C("j")
e = C("e")
h = A("h")
a = A("a")

c.s = j
c.p = b
b.v = j
j.q = e
j.t = b
e.q = j
e.t = b
h.s = e
h.p = b
a.s = e
a.p = b
assert b.v.t.v.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.p: B = None
        self.txt = txt

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

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

c = A("c")
b = B("b")
j = C("j")
e = C("e")
h = A("h")
a = A("a")

c.s = j
c.p = b
b.v = j
j.q = e
j.t = b
e.q = j
e.t = b
h.s = e
h.p = b
a.s = e
a.p = b
assert b.v.t.v.q.t.txt == "b"