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

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

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

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

l = A("l")
f = B("f")
d = C("d")
m = D("m")
k = B("k")
a = C("a")
i = D("i")
g = A("g")
j = C("j")

l.v = k
l.x = d
f.p = g
d.y = l
m.w = a
m.y = g
m.v = i
k.p = l
a.y = g
i.w = a
i.y = l
i.v = m
g.v = f
g.x = a
j.y = g
assert g.x.y.x.y.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: C = None
        self.txt = txt

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

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

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

l = A("l")
f = B("f")
d = C("d")
m = D("m")
k = B("k")
a = C("a")
i = D("i")
g = A("g")
j = C("j")

l.v = k
l.x = d
f.p = g
d.y = l
m.w = a
m.y = g
m.v = i
k.p = l
a.y = g
i.w = a
i.y = l
i.v = m
g.v = f
g.x = a
j.y = g
assert g.x.y.x.y.v.p.txt == "g"