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

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

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

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

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

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

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

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

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

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

f.r = c
f.y = c
f.v = n
f.o = m
a.s = d
a.w = n
c.y = l
c.q = f
c.p = d
n.q = g
h.y = l
h.q = f
h.p = n
g.r = e
g.v = n
g.o = a
g.y = c
e.y = l
e.q = l
e.p = n
d.q = g
m.s = n
m.w = d
l.r = c
l.y = c
l.v = n
l.o = a
assert e.y.o.s.q.r.p.q.o.txt == "a"