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

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

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

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

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

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

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

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

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

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

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