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

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

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

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

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

m.p = h
m.y = d
m.v = f
l.v = h
h.o = b
h.w = j
h.z = l
f.u = b
f.x = e
f.o = j
e.u = d
e.x = c
e.o = h
c.u = d
c.x = e
c.o = h
j.o = d
j.w = h
j.z = l
b.p = j
b.y = d
b.v = e
d.p = j
d.y = m
d.v = f
assert l.v.w.w.z.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: A = None
        self.v: D = None
        self.txt = txt

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

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

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

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

m.p = h
m.y = d
m.v = f
l.v = h
h.o = b
h.w = j
h.z = l
f.u = b
f.x = e
f.o = j
e.u = d
e.x = c
e.o = h
c.u = d
c.x = e
c.o = h
j.o = d
j.w = h
j.z = l
b.p = j
b.y = d
b.v = e
d.p = j
d.y = m
d.v = f
assert l.v.w.w.z.v.z.v.txt == "h"