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

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

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

i = A("i")
m = B("m")
j = C("j")
g = C("g")
a = B("a")
f = C("f")
e = C("e")
h = A("h")
b = C("b")
d = C("d")

i.q = h
i.w = e
m.u = a
m.y = b
j.s = m
j.v = i
g.s = m
g.v = h
a.u = m
a.y = d
f.s = a
f.v = h
e.s = m
e.v = h
h.q = i
h.w = g
b.s = a
b.v = i
d.s = a
d.v = h
assert j.s.y.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: C = None
        self.txt = txt

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

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

i = A("i")
m = B("m")
j = C("j")
g = C("g")
a = B("a")
f = C("f")
e = C("e")
h = A("h")
b = C("b")
d = C("d")

i.q = h
i.w = e
m.u = a
m.y = b
j.s = m
j.v = i
g.s = m
g.v = h
a.u = m
a.y = d
f.s = a
f.v = h
e.s = m
e.v = h
h.q = i
h.w = g
b.s = a
b.v = i
d.s = a
d.v = h
assert j.s.y.s.y.txt == "d"