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

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

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

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

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

h.p = a
h.x = a
h.q = g
f.r = a
f.w = a
f.p = h
i.w = h
i.v = n
i.o = a
i.x = k
a.q = h
d.w = k
d.x = k
d.v = f
d.o = a
k.p = a
k.q = g
k.x = g
b.w = h
b.x = h
b.v = n
b.o = g
g.q = h
n.r = a
n.w = g
n.p = h
assert h.p.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.q: D = None
        self.x: D = None
        self.txt = txt

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

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

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

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

h.p = a
h.x = a
h.q = g
f.r = a
f.w = a
f.p = h
i.w = h
i.v = n
i.o = a
i.x = k
a.q = h
d.w = k
d.x = k
d.v = f
d.o = a
k.p = a
k.q = g
k.x = g
b.w = h
b.x = h
b.v = n
b.o = g
g.q = h
n.r = a
n.w = g
n.p = h
assert h.p.q.x.txt == "a"