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

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

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

h = A("h")
g = B("g")
j = C("j")
m = A("m")
i = C("i")
l = B("l")
e = B("e")

h.v = g
h.t = g
h.p = m
g.p = m
j.p = i
m.v = e
m.t = g
m.p = h
i.p = j
l.p = m
e.p = m
assert g.p.v.p.t.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.t: B = None
        self.p: A = None
        self.txt = txt

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

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

h = A("h")
g = B("g")
j = C("j")
m = A("m")
i = C("i")
l = B("l")
e = B("e")

h.v = g
h.t = g
h.p = m
g.p = m
j.p = i
m.v = e
m.t = g
m.p = h
i.p = j
l.p = m
e.p = m
assert g.p.v.p.t.p.p.txt == "h"