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

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

class C:
    def __init__(self, txt: str):
        self.q: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

g = A("g")
j = B("j")
h = C("h")
b = D("b")
n = E("n")
m = F("m")
l = D("l")
k = E("k")

g.y = j
j.s = g
j.q = k
j.y = h
h.q = m
b.u = m
b.t = m
b.p = j
b.z = j
b.y = l
b.r = g
n.u = k
n.x = m
n.y = m
n.t = g
m.s = h
l.u = m
l.t = m
l.p = j
l.z = j
l.y = b
l.r = g
k.u = n
k.x = m
k.y = m
k.t = g
assert h.q.s.q.s.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

g = A("g")
j = B("j")
h = C("h")
b = D("b")
n = E("n")
m = F("m")
l = D("l")
k = E("k")

g.y = j
j.s = g
j.q = k
j.y = h
h.q = m
b.u = m
b.t = m
b.p = j
b.z = j
b.y = l
b.r = g
n.u = k
n.x = m
n.y = m
n.t = g
m.s = h
l.u = m
l.t = m
l.p = j
l.z = j
l.y = b
l.r = g
k.u = n
k.x = m
k.y = m
k.t = g
assert h.q.s.q.s.q.s.txt == "h"