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

class B:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: D = None
        self.o: B = None
        self.s: D = None
        self.txt = txt

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

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

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

d.r = l
d.z = g
d.o = f
d.s = c
l.w = c
l.o = c
l.x = f
l.s = h
j.x = c
j.o = c
j.u = a
j.w = l
a.r = h
f.r = a
h.r = f
c.w = l
c.o = l
c.x = h
c.s = a
g.r = c
g.z = d
g.o = h
g.s = l
assert g.r.x.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: A = None
        self.o: D = None
        self.s: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: D = None
        self.o: B = None
        self.s: D = None
        self.txt = txt

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

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

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

d.r = l
d.z = g
d.o = f
d.s = c
l.w = c
l.o = c
l.x = f
l.s = h
j.x = c
j.o = c
j.u = a
j.w = l
a.r = h
f.r = a
h.r = f
c.w = l
c.o = l
c.x = h
c.s = a
g.r = c
g.z = d
g.o = h
g.s = l
assert g.r.x.r.r.txt == "a"