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

class B:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: B = None
        self.w: B = None
        self.txt = txt

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

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

h = A("h")
j = B("j")
n = C("n")
c = D("c")
l = C("l")
d = A("d")
k = B("k")
g = B("g")

h.x = j
h.u = d
h.r = l
j.r = k
j.w = k
j.z = g
n.w = k
n.r = h
c.r = h
l.w = k
l.r = h
d.x = g
d.u = h
d.r = n
k.r = j
k.z = j
k.w = j
g.r = j
g.w = j
g.z = k
assert c.r.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.u: A = None
        self.r: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: B = None
        self.w: B = None
        self.txt = txt

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

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

h = A("h")
j = B("j")
n = C("n")
c = D("c")
l = C("l")
d = A("d")
k = B("k")
g = B("g")

h.x = j
h.u = d
h.r = l
j.r = k
j.w = k
j.z = g
n.w = k
n.r = h
c.r = h
l.w = k
l.r = h
d.x = g
d.u = h
d.r = n
k.r = j
k.z = j
k.w = j
g.r = j
g.w = j
g.z = k
assert c.r.x.z.txt == "g"