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

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

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: D = None
        self.q: D = None
        self.r: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: D = None
        self.o: D = None
        self.s: C = None
        self.txt = txt

d = A("d")
h = B("h")
j = C("j")
f = D("f")
n = B("n")
i = D("i")
b = D("b")
g = C("g")
e = C("e")

d.y = f
h.z = n
j.u = d
j.t = i
j.q = i
j.r = n
f.y = i
f.o = i
f.s = j
n.z = h
i.y = f
i.o = f
i.s = j
b.y = i
b.o = f
b.s = j
g.u = d
g.t = i
g.q = b
g.r = h
e.u = d
e.t = i
e.q = f
e.r = n
assert j.q.s.q.o.o.y.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: D = None
        self.q: D = None
        self.r: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: D = None
        self.o: D = None
        self.s: C = None
        self.txt = txt

d = A("d")
h = B("h")
j = C("j")
f = D("f")
n = B("n")
i = D("i")
b = D("b")
g = C("g")
e = C("e")

d.y = f
h.z = n
j.u = d
j.t = i
j.q = i
j.r = n
f.y = i
f.o = i
f.s = j
n.z = h
i.y = f
i.o = f
i.s = j
b.y = i
b.o = f
b.s = j
g.u = d
g.t = i
g.q = b
g.r = h
e.u = d
e.t = i
e.q = f
e.r = n
assert j.q.s.q.o.o.y.o.y.txt == "f"