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

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

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

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

h = A("h")
m = B("m")
j = C("j")
a = D("a")
f = D("f")
k = B("k")
g = A("g")
n = C("n")
d = D("d")
b = B("b")

h.p = b
h.q = d
h.s = j
m.x = h
j.r = a
a.v = f
a.w = b
a.r = g
a.t = h
f.v = d
f.w = b
f.r = h
f.t = h
k.x = h
g.p = k
g.q = f
g.s = n
n.r = a
d.v = a
d.w = m
d.r = h
d.t = h
b.x = g
assert h.p.x.p.x.p.x.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: D = None
        self.s: C = None
        self.txt = txt

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

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

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

h = A("h")
m = B("m")
j = C("j")
a = D("a")
f = D("f")
k = B("k")
g = A("g")
n = C("n")
d = D("d")
b = B("b")

h.p = b
h.q = d
h.s = j
m.x = h
j.r = a
a.v = f
a.w = b
a.r = g
a.t = h
f.v = d
f.w = b
f.r = h
f.t = h
k.x = h
g.p = k
g.q = f
g.s = n
n.r = a
d.v = a
d.w = m
d.r = h
d.t = h
b.x = g
assert h.p.x.p.x.p.x.q.r.txt == "h"