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

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

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

class D:
    def __init__(self, txt: str):
        self.v: D = None
        self.u: C = None
        self.p: A = None
        self.s: D = None
        self.txt = txt

l = A("l")
g = B("g")
e = C("e")
m = D("m")
c = A("c")
f = C("f")
n = D("n")

l.q = e
l.r = f
g.w = e
g.s = l
e.w = g
e.r = c
m.v = n
m.s = n
m.u = f
m.p = l
c.q = f
c.r = f
f.w = g
f.r = c
n.v = m
n.s = m
n.u = f
n.p = c
assert g.w.r.r.w.w.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.r: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: D = None
        self.u: C = None
        self.p: A = None
        self.s: D = None
        self.txt = txt

l = A("l")
g = B("g")
e = C("e")
m = D("m")
c = A("c")
f = C("f")
n = D("n")

l.q = e
l.r = f
g.w = e
g.s = l
e.w = g
e.r = c
m.v = n
m.s = n
m.u = f
m.p = l
c.q = f
c.r = f
f.w = g
f.r = c
n.v = m
n.s = m
n.u = f
n.p = c
assert g.w.r.r.w.w.r.q.txt == "f"