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

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

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

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

g = A("g")
d = B("d")
h = C("h")
e = D("e")
m = B("m")
l = A("l")
j = B("j")
f = D("f")

g.u = j
d.p = h
h.w = l
e.s = m
e.v = h
e.w = h
e.x = f
m.p = h
l.u = j
j.p = h
f.s = d
f.v = h
f.w = h
f.x = e
assert l.u.p.w.u.p.w.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

g = A("g")
d = B("d")
h = C("h")
e = D("e")
m = B("m")
l = A("l")
j = B("j")
f = D("f")

g.u = j
d.p = h
h.w = l
e.s = m
e.v = h
e.w = h
e.x = f
m.p = h
l.u = j
j.p = h
f.s = d
f.v = h
f.w = h
f.x = e
assert l.u.p.w.u.p.w.u.p.txt == "h"