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

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

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

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

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

g.q = m
g.p = j
g.s = l
h.t = g
h.q = i
l.o = j
l.w = j
l.q = j
l.v = g
d.p = i
m.t = g
m.q = i
a.t = g
a.q = i
j.o = l
j.w = l
j.q = l
j.v = g
i.p = d
b.t = g
b.q = i
assert l.v.q.t.q.q.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: C = None
        self.s: C = None
        self.txt = txt

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

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

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

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

g.q = m
g.p = j
g.s = l
h.t = g
h.q = i
l.o = j
l.w = j
l.q = j
l.v = g
d.p = i
m.t = g
m.q = i
a.t = g
a.q = i
j.o = l
j.w = l
j.q = l
j.v = g
i.p = d
b.t = g
b.q = i
assert l.v.q.t.q.q.p.p.p.p.txt == "i"