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

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

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

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

m = A("m")
d = B("d")
k = C("k")
l = D("l")
e = A("e")
i = B("i")
g = C("g")

m.p = k
m.v = e
m.w = l
d.s = i
d.x = e
k.t = l
l.y = e
l.u = i
l.p = i
l.v = i
e.p = k
e.v = m
e.w = l
i.s = d
i.x = e
g.t = l
assert i.x.v.w.v.x.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: A = None
        self.w: D = None
        self.txt = txt

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

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

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

m = A("m")
d = B("d")
k = C("k")
l = D("l")
e = A("e")
i = B("i")
g = C("g")

m.p = k
m.v = e
m.w = l
d.s = i
d.x = e
k.t = l
l.y = e
l.u = i
l.p = i
l.v = i
e.p = k
e.v = m
e.w = l
i.s = d
i.x = e
g.t = l
assert i.x.v.w.v.x.p.t.txt == "l"