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

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

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

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

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

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

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

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

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

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

l.q = g
l.x = j
g.q = c
b.w = a
b.u = a
m.t = i
m.y = i
m.r = l
m.x = a
n.w = g
n.u = a
a.q = c
i.q = g
i.x = d
j.w = a
j.u = a
c.t = l
c.r = l
c.y = l
c.x = a
d.w = g
d.u = g
assert l.x.w.q.y.q.q.x.q.x.q.txt == "c"