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

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

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

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

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

h.o = j
g.x = c
g.v = c
g.y = h
g.w = e
c.r = h
c.z = m
c.w = j
j.r = e
j.v = e
j.w = c
m.x = c
m.v = c
m.y = h
m.w = j
f.x = c
f.v = c
f.y = h
f.w = e
e.r = j
e.v = j
e.w = c
assert j.w.r.o.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

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

h.o = j
g.x = c
g.v = c
g.y = h
g.w = e
c.r = h
c.z = m
c.w = j
j.r = e
j.v = e
j.w = c
m.x = c
m.v = c
m.y = h
m.w = j
f.x = c
f.v = c
f.y = h
f.w = e
e.r = j
e.v = j
e.w = c
assert j.w.r.o.w.z.txt == "m"