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

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

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

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

a = A("a")
f = B("f")
m = C("m")
d = D("d")
b = B("b")
k = C("k")
g = C("g")
e = D("e")

a.r = f
f.v = g
f.o = g
f.t = e
f.y = a
m.x = k
m.o = g
m.q = f
m.s = e
d.p = e
b.v = g
b.o = g
b.t = e
b.y = a
k.x = g
k.o = g
k.q = b
k.s = d
g.x = k
g.o = k
g.q = b
g.s = e
e.p = d
assert f.o.q.v.q.y.r.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

a = A("a")
f = B("f")
m = C("m")
d = D("d")
b = B("b")
k = C("k")
g = C("g")
e = D("e")

a.r = f
f.v = g
f.o = g
f.t = e
f.y = a
m.x = k
m.o = g
m.q = f
m.s = e
d.p = e
b.v = g
b.o = g
b.t = e
b.y = a
k.x = g
k.o = g
k.q = b
k.s = d
g.x = k
g.o = k
g.q = b
g.s = e
e.p = d
assert f.o.q.v.q.y.r.v.q.txt == "b"