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

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

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

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

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

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

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

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

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

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

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