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

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: D = None
        self.txt = txt

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

a = A("a")
b = B("b")
g = C("g")
m = D("m")
k = A("k")
f = B("f")
n = B("n")

a.p = m
b.u = a
b.r = k
b.x = f
b.v = f
g.s = k
g.z = m
m.x = a
k.p = m
f.u = k
f.r = k
f.x = n
f.v = b
n.u = k
n.r = a
n.x = b
n.v = f
assert f.v.u.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: D = None
        self.txt = txt

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

a = A("a")
b = B("b")
g = C("g")
m = D("m")
k = A("k")
f = B("f")
n = B("n")

a.p = m
b.u = a
b.r = k
b.x = f
b.v = f
g.s = k
g.z = m
m.x = a
k.p = m
f.u = k
f.r = k
f.x = n
f.v = b
n.u = k
n.r = a
n.x = b
n.v = f
assert f.v.u.p.x.txt == "a"