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

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

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

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

b = A("b")
a = B("a")
f = C("f")
m = D("m")
n = D("n")
g = A("g")
i = C("i")

b.r = n
b.x = g
b.w = i
b.q = a
a.q = m
a.o = f
a.r = n
f.y = n
f.q = a
f.u = i
m.v = a
m.u = a
n.v = a
n.u = a
g.r = m
g.x = b
g.w = f
g.q = a
i.y = n
i.q = a
i.u = f
assert a.o.u.y.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.x: A = None
        self.w: C = None
        self.q: B = None
        self.txt = txt

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

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

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

b = A("b")
a = B("a")
f = C("f")
m = D("m")
n = D("n")
g = A("g")
i = C("i")

b.r = n
b.x = g
b.w = i
b.q = a
a.q = m
a.o = f
a.r = n
f.y = n
f.q = a
f.u = i
m.v = a
m.u = a
n.v = a
n.u = a
g.r = m
g.x = b
g.w = f
g.q = a
i.y = n
i.q = a
i.u = f
assert a.o.u.y.u.r.u.txt == "a"