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

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

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

d = A("d")
i = B("i")
n = C("n")
g = A("g")
j = A("j")
a = A("a")
h = B("h")
k = A("k")

d.u = i
d.y = g
d.x = h
i.x = h
i.w = a
n.s = h
g.u = i
g.x = i
g.y = a
j.u = i
j.y = d
j.x = h
a.u = i
a.x = i
a.y = j
h.x = i
h.w = j
k.u = h
k.y = j
k.x = i
assert g.y.y.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: A = None
        self.x: B = None
        self.txt = txt

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

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

d = A("d")
i = B("i")
n = C("n")
g = A("g")
j = A("j")
a = A("a")
h = B("h")
k = A("k")

d.u = i
d.y = g
d.x = h
i.x = h
i.w = a
n.s = h
g.u = i
g.x = i
g.y = a
j.u = i
j.y = d
j.x = h
a.u = i
a.x = i
a.y = j
h.x = i
h.w = j
k.u = h
k.y = j
k.x = i
assert g.y.y.y.u.txt == "i"