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

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

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

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

g = A("g")
h = B("h")
j = C("j")
d = D("d")
k = D("k")
l = D("l")
m = D("m")
n = B("n")
e = D("e")
i = C("i")

g.r = h
g.q = k
g.u = n
h.u = e
h.w = n
j.y = k
j.v = n
d.r = h
k.r = h
l.r = h
m.r = n
n.u = l
n.w = h
e.r = h
i.y = m
i.v = n
assert l.r.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: D = None
        self.u: B = None
        self.txt = txt

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

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

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

g = A("g")
h = B("h")
j = C("j")
d = D("d")
k = D("k")
l = D("l")
m = D("m")
n = B("n")
e = D("e")
i = C("i")

g.r = h
g.q = k
g.u = n
h.u = e
h.w = n
j.y = k
j.v = n
d.r = h
k.r = h
l.r = h
m.r = n
n.u = l
n.w = h
e.r = h
i.y = m
i.v = n
assert l.r.w.u.txt == "l"