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

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

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

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

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

f.q = n
f.s = g
f.y = h
f.v = h
h.w = g
c.u = a
c.x = g
n.w = h
i.u = a
i.x = f
k.w = f
a.u = c
a.x = g
g.q = n
g.s = f
g.y = h
g.v = h
assert n.w.w.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.s: A = None
        self.y: B = None
        self.v: B = None
        self.txt = txt

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

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

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

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

f.q = n
f.s = g
f.y = h
f.v = h
h.w = g
c.u = a
c.x = g
n.w = h
i.u = a
i.x = f
k.w = f
a.u = c
a.x = g
g.q = n
g.s = f
g.y = h
g.v = h
assert n.w.w.y.w.txt == "g"