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

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

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

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

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

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

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

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

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

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

f.y = b
f.q = j
f.w = d
e.q = f
e.t = d
e.o = b
l.s = j
h.w = d
h.u = l
j.w = d
j.u = l
d.q = b
d.t = e
d.o = f
b.y = g
b.q = h
b.w = d
g.y = f
g.q = h
g.w = e
assert h.u.s.u.s.u.s.u.s.txt == "j"