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

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

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

c = A("c")
j = B("j")
l = C("l")
d = A("d")
n = B("n")
e = B("e")
i = B("i")
b = B("b")
g = C("g")
m = A("m")

c.p = i
j.t = g
l.s = m
d.p = b
n.t = l
e.t = g
i.t = l
b.t = g
g.s = c
m.p = b
assert m.p.t.s.p.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

c = A("c")
j = B("j")
l = C("l")
d = A("d")
n = B("n")
e = B("e")
i = B("i")
b = B("b")
g = C("g")
m = A("m")

c.p = i
j.t = g
l.s = m
d.p = b
n.t = l
e.t = g
i.t = l
b.t = g
g.s = c
m.p = b
assert m.p.t.s.p.t.s.txt == "m"