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

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

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

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

n = A("n")
i = B("i")
g = C("g")
h = D("h")
j = A("j")
m = C("m")
c = B("c")
l = C("l")

n.u = l
i.q = c
i.x = c
i.u = n
i.v = g
g.p = m
g.x = m
g.t = i
g.r = h
h.z = m
j.u = g
m.p = g
m.t = c
m.x = l
m.r = h
c.q = i
c.x = i
c.u = j
c.v = l
l.p = g
l.x = g
l.t = c
l.r = h
assert c.u.u.p.r.z.t.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

n = A("n")
i = B("i")
g = C("g")
h = D("h")
j = A("j")
m = C("m")
c = B("c")
l = C("l")

n.u = l
i.q = c
i.x = c
i.u = n
i.v = g
g.p = m
g.x = m
g.t = i
g.r = h
h.z = m
j.u = g
m.p = g
m.t = c
m.x = l
m.r = h
c.q = i
c.x = i
c.u = j
c.v = l
l.p = g
l.x = g
l.t = c
l.r = h
assert c.u.u.p.r.z.t.u.u.txt == "g"