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

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

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

h = A("h")
i = B("i")
d = C("d")
m = C("m")
j = C("j")
n = B("n")

h.s = d
i.q = n
i.p = j
d.t = n
d.x = m
m.t = i
m.x = d
j.t = i
j.x = d
n.q = i
n.p = j
assert j.t.q.p.t.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

h = A("h")
i = B("i")
d = C("d")
m = C("m")
j = C("j")
n = B("n")

h.s = d
i.q = n
i.p = j
d.t = n
d.x = m
m.t = i
m.x = d
j.t = i
j.x = d
n.q = i
n.p = j
assert j.t.q.p.t.p.t.txt == "i"