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

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

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

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

b = A("b")
m = B("m")
i = C("i")
g = D("g")
a = B("a")
h = B("h")
j = A("j")
l = D("l")

b.u = l
b.w = i
b.s = j
b.o = j
m.w = b
m.y = j
m.u = j
i.p = m
i.u = b
g.u = i
a.w = j
a.y = j
a.u = j
h.w = b
h.y = b
h.u = b
j.u = g
j.w = i
j.s = b
j.o = b
l.u = i
assert m.w.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.w: C = None
        self.s: A = None
        self.o: A = None
        self.txt = txt

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

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

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

b = A("b")
m = B("m")
i = C("i")
g = D("g")
a = B("a")
h = B("h")
j = A("j")
l = D("l")

b.u = l
b.w = i
b.s = j
b.o = j
m.w = b
m.y = j
m.u = j
i.p = m
i.u = b
g.u = i
a.w = j
a.y = j
a.u = j
h.w = b
h.y = b
h.u = b
j.u = g
j.w = i
j.s = b
j.o = b
l.u = i
assert m.w.u.u.u.u.u.txt == "i"