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

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

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

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

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

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

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

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

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

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

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