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

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

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

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

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

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

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

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

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

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

g.x = n
g.z = n
g.q = i
g.t = f
n.w = j
n.s = f
l.y = f
l.r = h
c.p = f
c.y = j
c.u = g
c.q = n
j.y = l
j.r = d
f.y = l
f.r = b
i.p = l
i.y = j
i.u = h
i.q = n
b.x = n
b.z = n
b.q = i
b.t = f
h.x = n
h.z = n
h.q = c
h.t = j
d.x = n
d.z = n
d.q = c
d.t = l
assert n.s.r.q.p.r.q.u.z.s.txt == "f"