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

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

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

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

b = A("b")
m = B("m")
j = C("j")
d = D("d")
h = A("h")
i = D("i")
a = B("a")
f = A("f")
n = B("n")

b.t = h
b.o = n
b.x = n
b.w = f
m.u = b
m.s = d
j.v = b
j.r = m
d.u = j
h.t = f
h.w = f
h.o = a
h.x = n
i.u = j
a.u = h
a.s = d
f.t = b
f.o = a
f.x = a
f.w = h
n.u = b
n.s = d
assert d.u.r.s.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.o: B = None
        self.x: B = None
        self.w: A = None
        self.txt = txt

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

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

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

b = A("b")
m = B("m")
j = C("j")
d = D("d")
h = A("h")
i = D("i")
a = B("a")
f = A("f")
n = B("n")

b.t = h
b.o = n
b.x = n
b.w = f
m.u = b
m.s = d
j.v = b
j.r = m
d.u = j
h.t = f
h.w = f
h.o = a
h.x = n
i.u = j
a.u = h
a.s = d
f.t = b
f.o = a
f.x = a
f.w = h
n.u = b
n.s = d
assert d.u.r.s.u.r.txt == "m"