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

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

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

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

f = A("f")
g = B("g")
j = C("j")
c = D("c")
m = C("m")
n = A("n")
i = C("i")
a = B("a")
d = C("d")

f.t = n
f.q = a
f.x = j
g.t = n
g.w = j
j.u = g
j.r = m
c.y = g
c.z = n
c.t = n
m.u = g
m.r = j
n.t = f
n.q = a
n.x = j
i.u = g
i.r = j
a.t = n
a.w = m
d.u = g
d.r = m
assert f.t.x.r.u.w.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: B = None
        self.x: C = None
        self.txt = txt

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

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

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

f = A("f")
g = B("g")
j = C("j")
c = D("c")
m = C("m")
n = A("n")
i = C("i")
a = B("a")
d = C("d")

f.t = n
f.q = a
f.x = j
g.t = n
g.w = j
j.u = g
j.r = m
c.y = g
c.z = n
c.t = n
m.u = g
m.r = j
n.t = f
n.q = a
n.x = j
i.u = g
i.r = j
a.t = n
a.w = m
d.u = g
d.r = m
assert f.t.x.r.u.w.r.r.r.txt == "m"