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

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

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

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

c = A("c")
m = B("m")
a = C("a")
g = D("g")
f = B("f")
h = A("h")
j = D("j")

c.u = g
c.s = m
c.z = a
m.y = a
m.x = g
m.z = c
a.x = j
g.w = j
g.p = a
f.y = a
f.x = j
f.z = h
h.u = j
h.s = f
h.z = a
j.w = g
j.p = a
assert f.x.w.p.x.p.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.s: B = None
        self.z: C = None
        self.txt = txt

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

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

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

c = A("c")
m = B("m")
a = C("a")
g = D("g")
f = B("f")
h = A("h")
j = D("j")

c.u = g
c.s = m
c.z = a
m.y = a
m.x = g
m.z = c
a.x = j
g.w = j
g.p = a
f.y = a
f.x = j
f.z = h
h.u = j
h.s = f
h.z = a
j.w = g
j.p = a
assert f.x.w.p.x.p.x.w.txt == "g"