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

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

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: B = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: B = None
        self.txt = txt

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

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

c.u = n
c.w = h
c.z = m
c.t = d
a.z = b
a.q = n
a.s = m
a.x = c
h.y = m
h.q = m
b.r = a
b.y = d
b.x = c
f.y = a
f.q = a
g.u = c
g.w = f
g.z = a
g.t = d
d.r = m
d.y = b
d.x = k
k.u = g
k.w = h
k.z = m
k.t = b
m.z = b
m.q = k
m.s = a
m.x = n
n.u = g
n.w = h
n.z = a
n.t = b
assert k.t.x.z.x.u.u.t.y.txt == "b"