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

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: F = None
        self.u: B = None
        self.r: E = None
        self.z: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

h = A("h")
d = B("d")
n = C("n")
a = D("a")
g = E("g")
m = F("m")
f = B("f")
b = A("b")
c = B("c")

h.p = f
h.w = b
h.x = a
d.u = n
n.s = d
n.w = m
n.u = f
n.r = g
n.z = g
a.r = n
a.u = m
g.y = h
m.v = a
m.q = h
m.y = h
m.t = b
f.u = n
b.p = c
b.w = h
b.x = a
c.u = n
assert m.t.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: A = None
        self.x: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: F = None
        self.u: B = None
        self.r: E = None
        self.z: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

h = A("h")
d = B("d")
n = C("n")
a = D("a")
g = E("g")
m = F("m")
f = B("f")
b = A("b")
c = B("c")

h.p = f
h.w = b
h.x = a
d.u = n
n.s = d
n.w = m
n.u = f
n.r = g
n.z = g
a.r = n
a.u = m
g.y = h
m.v = a
m.q = h
m.y = h
m.t = b
f.u = n
b.p = c
b.w = h
b.x = a
c.u = n
assert m.t.p.u.txt == "n"