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

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

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

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

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

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

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

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

b.p = e
b.s = n
b.t = h
c.s = b
c.u = b
g.v = b
h.v = e
n.s = b
n.u = b
a.v = b
e.p = b
e.s = c
e.t = h
assert g.v.p.t.v.s.txt == "c"