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

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

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

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

f = A("f")
e = B("e")
n = C("n")
c = D("c")
a = C("a")
g = B("g")
l = B("l")
i = B("i")
h = A("h")

f.z = g
f.x = g
f.w = n
f.u = c
e.s = c
n.r = f
c.q = a
c.w = f
a.r = h
g.s = c
l.s = c
i.s = c
h.z = i
h.w = n
h.x = l
h.u = c
assert g.s.q.r.w.r.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: C = None
        self.x: B = None
        self.u: D = None
        self.txt = txt

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

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

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

f = A("f")
e = B("e")
n = C("n")
c = D("c")
a = C("a")
g = B("g")
l = B("l")
i = B("i")
h = A("h")

f.z = g
f.x = g
f.w = n
f.u = c
e.s = c
n.r = f
c.q = a
c.w = f
a.r = h
g.s = c
l.s = c
i.s = c
h.z = i
h.w = n
h.x = l
h.u = c
assert g.s.q.r.w.r.u.q.txt == "a"