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

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

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

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

i = A("i")
a = B("a")
g = C("g")
j = D("j")
h = B("h")
b = D("b")

i.t = a
i.x = j
a.r = h
a.w = i
g.u = a
g.s = a
g.z = j
j.r = b
j.q = b
j.z = a
j.u = a
h.r = a
h.w = i
b.r = j
b.q = j
b.z = h
b.u = a
assert a.w.t.w.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: D = None
        self.txt = txt

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

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

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

i = A("i")
a = B("a")
g = C("g")
j = D("j")
h = B("h")
b = D("b")

i.t = a
i.x = j
a.r = h
a.w = i
g.u = a
g.s = a
g.z = j
j.r = b
j.q = b
j.z = a
j.u = a
h.r = a
h.w = i
b.r = j
b.q = j
b.z = h
b.u = a
assert a.w.t.w.t.w.t.txt == "a"