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

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

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

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

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

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

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

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

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

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

i.q = b
i.r = g
i.x = m
k.y = g
m.u = b
m.s = l
m.w = d
g.s = f
n.q = b
n.r = g
n.x = m
f.u = b
f.w = b
f.s = c
l.y = g
d.q = n
d.r = g
d.x = m
b.q = d
b.r = g
b.x = m
c.y = g
assert c.y.s.s.y.s.u.q.r.s.txt == "f"