class A:
    def __init__(self, txt: str):
        self.p: G = None
        self.x: E = None
        self.t: E = None
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: F = None
        self.t: F = None
        self.z: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: G = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: E = None
        self.t: B = None
        self.txt = txt

h = A("h")
n = B("n")
m = C("m")
j = D("j")
a = E("a")
e = F("e")
g = G("g")
b = E("b")
l = A("l")
d = B("d")

h.p = g
h.x = b
h.t = b
h.q = m
n.p = e
n.t = e
n.z = l
m.x = j
j.x = l
j.u = g
a.u = g
e.p = d
g.p = d
g.y = b
g.t = n
b.u = g
l.p = g
l.x = a
l.t = b
l.q = m
d.p = e
d.t = e
d.z = h
assert g.p.z.p.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: G = None
        self.x: E = None
        self.t: E = None
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: F = None
        self.t: F = None
        self.z: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: G = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: E = None
        self.t: B = None
        self.txt = txt

h = A("h")
n = B("n")
m = C("m")
j = D("j")
a = E("a")
e = F("e")
g = G("g")
b = E("b")
l = A("l")
d = B("d")

h.p = g
h.x = b
h.t = b
h.q = m
n.p = e
n.t = e
n.z = l
m.x = j
j.x = l
j.u = g
a.u = g
e.p = d
g.p = d
g.y = b
g.t = n
b.u = g
l.p = g
l.x = a
l.t = b
l.q = m
d.p = e
d.t = e
d.z = h
assert g.p.z.p.y.u.txt == "g"