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

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

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

f = A("f")
m = B("m")
n = C("n")
l = A("l")
c = C("c")
h = B("h")

f.x = m
f.v = m
f.p = h
m.t = f
m.p = c
m.o = h
n.v = h
l.x = m
l.p = h
l.v = h
c.v = m
h.t = f
h.p = c
h.o = m
assert l.x.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: B = None
        self.v: B = None
        self.txt = txt

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

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

f = A("f")
m = B("m")
n = C("n")
l = A("l")
c = C("c")
h = B("h")

f.x = m
f.v = m
f.p = h
m.t = f
m.p = c
m.o = h
n.v = h
l.x = m
l.p = h
l.v = h
c.v = m
h.t = f
h.p = c
h.o = m
assert l.x.p.v.txt == "m"