class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: C = None
        self.v: 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.v: B = None
        self.p: A = None
        self.txt = txt

i = A("i")
b = B("b")
d = C("d")
f = C("f")
e = A("e")
g = B("g")
j = C("j")
m = B("m")

i.p = b
i.s = f
i.v = g
b.t = f
d.v = b
d.p = i
f.v = m
f.p = e
e.p = g
e.s = d
e.v = b
g.t = j
j.v = b
j.p = e
m.t = f
assert g.t.v.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: C = None
        self.v: 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.v: B = None
        self.p: A = None
        self.txt = txt

i = A("i")
b = B("b")
d = C("d")
f = C("f")
e = A("e")
g = B("g")
j = C("j")
m = B("m")

i.p = b
i.s = f
i.v = g
b.t = f
d.v = b
d.p = i
f.v = m
f.p = e
e.p = g
e.s = d
e.v = b
g.t = j
j.v = b
j.p = e
m.t = f
assert g.t.v.t.v.txt == "m"