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

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

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

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

d = A("d")
k = B("k")
j = C("j")
l = D("l")
h = B("h")
g = D("g")

d.w = l
d.p = k
d.u = g
d.q = h
k.q = h
k.s = h
k.x = j
k.r = j
j.x = l
j.p = l
j.r = k
l.p = d
l.r = d
h.q = k
h.s = k
h.x = j
h.r = j
g.p = d
g.r = d
assert j.r.r.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.p: B = None
        self.u: D = None
        self.q: B = None
        self.txt = txt

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

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

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

d = A("d")
k = B("k")
j = C("j")
l = D("l")
h = B("h")
g = D("g")

d.w = l
d.p = k
d.u = g
d.q = h
k.q = h
k.s = h
k.x = j
k.r = j
j.x = l
j.p = l
j.r = k
l.p = d
l.r = d
h.q = k
h.s = k
h.x = j
h.r = j
g.p = d
g.r = d
assert j.r.r.r.q.txt == "h"