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

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

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

d = A("d")
f = B("f")
c = C("c")
m = A("m")
a = B("a")
h = C("h")

d.v = h
d.y = f
f.t = d
f.p = h
f.s = a
c.p = h
m.v = h
m.y = a
a.t = m
a.p = c
a.s = f
h.p = c
assert h.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.y: B = None
        self.txt = txt

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

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

d = A("d")
f = B("f")
c = C("c")
m = A("m")
a = B("a")
h = C("h")

d.v = h
d.y = f
f.t = d
f.p = h
f.s = a
c.p = h
m.v = h
m.y = a
a.t = m
a.p = c
a.s = f
h.p = c
assert h.p.p.p.p.txt == "h"