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

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

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

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

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

g.s = i
g.u = a
g.v = a
g.p = k
a.r = g
a.u = f
a.t = k
i.u = f
i.x = f
i.p = a
m.w = g
m.x = a
f.u = i
f.x = i
f.p = a
k.w = g
k.x = a
assert i.p.t.w.s.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.u: B = None
        self.v: B = None
        self.p: D = None
        self.txt = txt

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

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

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

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

g.s = i
g.u = a
g.v = a
g.p = k
a.r = g
a.u = f
a.t = k
i.u = f
i.x = f
i.p = a
m.w = g
m.x = a
f.u = i
f.x = i
f.p = a
k.w = g
k.x = a
assert i.p.t.w.s.x.p.txt == "a"