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

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

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

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

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

h.q = k
f.y = m
f.w = g
f.r = g
f.s = k
i.t = k
i.o = j
g.u = h
j.u = n
n.q = k
d.q = k
m.t = f
m.o = g
k.y = l
k.w = j
k.r = g
k.s = f
l.t = k
l.o = j
assert g.u.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

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

h.q = k
f.y = m
f.w = g
f.r = g
f.s = k
i.t = k
i.o = j
g.u = h
j.u = n
n.q = k
d.q = k
m.t = f
m.o = g
k.y = l
k.w = j
k.r = g
k.s = f
l.t = k
l.o = j
assert g.u.q.r.txt == "g"