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

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

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

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

m = A("m")
b = B("b")
i = C("i")
j = D("j")
g = B("g")
c = D("c")
e = C("e")
k = A("k")
l = D("l")

m.r = j
b.z = j
i.p = g
i.u = b
j.r = e
j.w = b
j.s = c
j.y = k
g.z = j
c.r = e
c.w = g
c.s = l
c.y = m
e.p = b
e.u = b
k.r = c
l.r = i
l.w = b
l.s = c
l.y = k
assert b.z.y.r.r.u.z.r.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

m = A("m")
b = B("b")
i = C("i")
j = D("j")
g = B("g")
c = D("c")
e = C("e")
k = A("k")
l = D("l")

m.r = j
b.z = j
i.p = g
i.u = b
j.r = e
j.w = b
j.s = c
j.y = k
g.z = j
c.r = e
c.w = g
c.s = l
c.y = m
e.p = b
e.u = b
k.r = c
l.r = i
l.w = b
l.s = c
l.y = k
assert b.z.y.r.r.u.z.r.u.z.txt == "j"