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

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

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

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

c = A("c")
f = B("f")
a = C("a")
e = D("e")
j = B("j")
h = C("h")
l = B("l")
g = D("g")
i = A("i")
n = D("n")

c.y = i
c.q = j
c.r = g
f.r = h
f.y = n
a.o = f
a.w = f
a.x = h
a.p = i
e.w = n
e.s = j
e.o = l
e.y = i
j.r = a
j.y = g
h.o = j
h.x = a
h.p = c
h.w = f
l.r = h
l.y = n
g.w = n
g.s = l
g.o = j
g.y = i
i.y = c
i.q = l
i.r = g
n.w = e
n.s = f
n.o = f
n.y = c
assert n.o.y.o.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: B = None
        self.r: D = None
        self.txt = txt

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

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

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

c = A("c")
f = B("f")
a = C("a")
e = D("e")
j = B("j")
h = C("h")
l = B("l")
g = D("g")
i = A("i")
n = D("n")

c.y = i
c.q = j
c.r = g
f.r = h
f.y = n
a.o = f
a.w = f
a.x = h
a.p = i
e.w = n
e.s = j
e.o = l
e.y = i
j.r = a
j.y = g
h.o = j
h.x = a
h.p = c
h.w = f
l.r = h
l.y = n
g.w = n
g.s = l
g.o = j
g.y = i
i.y = c
i.q = l
i.r = g
n.w = e
n.s = f
n.o = f
n.y = c
assert n.o.y.o.y.y.txt == "c"