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

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

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

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

h = A("h")
l = B("l")
k = C("k")
e = D("e")
d = A("d")
n = B("n")
m = B("m")

h.v = e
l.v = h
l.q = m
k.v = l
k.y = e
e.y = d
e.p = d
d.v = e
n.v = d
n.q = l
m.v = d
m.q = n
assert n.v.v.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
k = C("k")
e = D("e")
d = A("d")
n = B("n")
m = B("m")

h.v = e
l.v = h
l.q = m
k.v = l
k.y = e
e.y = d
e.p = d
d.v = e
n.v = d
n.q = l
m.v = d
m.q = n
assert n.v.v.p.v.txt == "e"