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

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

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

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

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

k.q = d
b.z = d
b.q = d
d.z = b
d.x = k
d.s = g
g.o = d
g.q = f
g.r = f
g.t = m
n.z = d
n.q = d
m.q = d
e.z = d
e.q = d
c.z = d
c.q = d
l.o = d
l.q = f
l.r = g
l.t = k
f.o = d
f.q = g
f.r = l
f.t = k
assert f.t.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

k.q = d
b.z = d
b.q = d
d.z = b
d.x = k
d.s = g
g.o = d
g.q = f
g.r = f
g.t = m
n.z = d
n.q = d
m.q = d
e.z = d
e.q = d
c.z = d
c.q = d
l.o = d
l.q = f
l.r = g
l.t = k
f.o = d
f.q = g
f.r = l
f.t = k
assert f.t.q.s.txt == "g"