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

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

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

b = A("b")
j = B("j")
l = C("l")
d = A("d")
a = B("a")
c = B("c")
h = B("h")
g = B("g")
n = C("n")
i = A("i")

b.x = c
b.q = n
j.r = d
j.y = d
j.s = i
l.u = b
l.o = d
d.x = c
d.q = l
a.r = i
a.y = b
a.s = d
c.r = i
c.s = i
c.y = b
h.r = i
h.y = d
h.s = b
g.r = d
g.y = d
g.s = d
n.u = i
n.o = b
i.x = c
i.q = l
assert j.y.x.s.q.o.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.q: C = None
        self.txt = txt

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

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

b = A("b")
j = B("j")
l = C("l")
d = A("d")
a = B("a")
c = B("c")
h = B("h")
g = B("g")
n = C("n")
i = A("i")

b.x = c
b.q = n
j.r = d
j.y = d
j.s = i
l.u = b
l.o = d
d.x = c
d.q = l
a.r = i
a.y = b
a.s = d
c.r = i
c.s = i
c.y = b
h.r = i
h.y = d
h.s = b
g.r = d
g.y = d
g.s = d
n.u = i
n.o = b
i.x = c
i.q = l
assert j.y.x.s.q.o.q.o.txt == "d"