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

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

d.v = c
d.x = h
g.v = c
c.y = l
c.r = g
c.q = b
m.o = g
m.s = d
m.q = d
i.y = m
i.r = f
i.q = b
f.v = b
l.o = g
l.s = d
l.q = d
b.y = j
b.r = h
b.q = i
j.o = h
j.s = d
j.q = d
h.v = b
assert h.v.q.q.txt == "b"