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

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

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

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

c = A("c")
d = B("d")
b = C("b")
f = D("f")
h = A("h")
a = B("a")
i = A("i")
k = B("k")
g = C("g")
m = D("m")

c.z = m
d.u = h
d.o = h
d.t = a
d.x = m
b.r = g
f.v = g
f.r = b
f.z = m
h.z = f
a.u = i
a.t = d
a.x = m
a.o = c
i.z = m
k.u = h
k.o = h
k.t = d
k.x = f
g.r = b
m.v = g
m.r = b
m.z = f
assert k.t.t.t.t.o.z.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

c = A("c")
d = B("d")
b = C("b")
f = D("f")
h = A("h")
a = B("a")
i = A("i")
k = B("k")
g = C("g")
m = D("m")

c.z = m
d.u = h
d.o = h
d.t = a
d.x = m
b.r = g
f.v = g
f.r = b
f.z = m
h.z = f
a.u = i
a.t = d
a.x = m
a.o = c
i.z = m
k.u = h
k.o = h
k.t = d
k.x = f
g.r = b
m.v = g
m.r = b
m.z = f
assert k.t.t.t.t.o.z.r.r.r.txt == "b"