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

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

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

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

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

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

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

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

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

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

f.v = i
f.o = k
f.t = k
f.y = g
g.q = m
i.y = b
i.p = a
i.q = g
k.q = f
k.t = m
k.r = i
b.y = i
b.p = a
b.q = g
a.y = i
a.p = b
a.q = g
m.q = f
m.t = k
m.r = a
assert a.p.q.q.r.q.q.txt == "m"