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

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: D = None
        self.txt = txt

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

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

d.y = h
c.o = a
c.z = h
c.r = g
c.w = b
b.s = h
b.q = n
f.z = b
f.r = c
a.o = g
a.r = g
a.z = h
a.w = b
h.y = d
n.z = b
n.r = c
l.o = c
l.r = c
l.z = h
l.w = b
g.o = c
g.r = c
g.z = d
g.w = b
assert g.o.z.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: D = None
        self.txt = txt

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

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

d.y = h
c.o = a
c.z = h
c.r = g
c.w = b
b.s = h
b.q = n
f.z = b
f.r = c
a.o = g
a.r = g
a.z = h
a.w = b
h.y = d
n.z = b
n.r = c
l.o = c
l.r = c
l.z = h
l.w = b
g.o = c
g.r = c
g.z = d
g.w = b
assert g.o.z.y.y.y.y.txt == "h"