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

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

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

l = A("l")
f = B("f")
e = C("e")
a = B("a")
k = B("k")
h = C("h")
d = A("d")
n = B("n")

l.v = d
f.p = n
f.o = a
f.x = l
e.w = h
a.p = k
a.o = n
a.x = d
k.p = f
k.o = a
k.x = d
h.w = e
d.v = l
n.p = f
n.o = k
n.x = d
assert k.p.p.o.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

l = A("l")
f = B("f")
e = C("e")
a = B("a")
k = B("k")
h = C("h")
d = A("d")
n = B("n")

l.v = d
f.p = n
f.o = a
f.x = l
e.w = h
a.p = k
a.o = n
a.x = d
k.p = f
k.o = a
k.x = d
h.w = e
d.v = l
n.p = f
n.o = k
n.x = d
assert k.p.p.o.x.v.txt == "l"