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

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

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

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

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

a.p = l
a.w = l
a.o = l
j.x = d
j.u = l
j.w = c
l.u = d
l.t = d
l.y = n
h.z = a
h.s = a
h.r = j
g.z = a
g.s = a
g.r = c
n.p = l
n.w = l
n.o = l
c.x = j
c.u = l
c.w = d
m.z = n
m.s = n
m.r = j
d.x = c
d.w = c
d.u = l
assert m.z.o.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: C = None
        self.o: C = None
        self.txt = txt

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

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

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

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

a.p = l
a.w = l
a.o = l
j.x = d
j.u = l
j.w = c
l.u = d
l.t = d
l.y = n
h.z = a
h.s = a
h.r = j
g.z = a
g.s = a
g.r = c
n.p = l
n.w = l
n.o = l
c.x = j
c.u = l
c.w = d
m.z = n
m.s = n
m.r = j
d.x = c
d.w = c
d.u = l
assert m.z.o.t.u.txt == "l"